简体   繁体   中英

Rewrite urls php/mysql page with htaccess apache

I have a search form to search for a health institution in a city. when I display the results I have this url for example: search.php?city=mycity&speciality=cardiology

I would like to rewrite this url like this: health-institution-cardiology-mycity

I set up an htaccess rule like this:

RewriteEngine on
RewriteRule health-entity-([a-zA-Z\-]+)-([a-zA-Z\-]+) search.php?city=$2&speciality=$1

It doesn't work, however I applied this rule on an other type of url and it works

is there any issue with the code? do i need to add something?

This will work:

RewriteEngine on
RewriteRule ^health-institution-([a-z]+)-([a-z]+)/?$ search.php?city=$2&speciality=$1 [NC,L]

Note: The NC (No Case) at the end makes the rurl case insensitive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM