.htaccess - htaccess rewrite query string nothing works -


the problem

after looking @ 50+ stackoverflow posts , trying many permutations of htaccess file, nothing still.

what have tried

using website generate htaccess file: http://www.generateit.net/mod-rewrite/

setting allowoverride in httpd.conf file , restarting apache.

my current htaccess file

lives in root directory.

rewriteengine on rewritebase / rewriterule ^find-a-local-doctor/([^/]*)/([^/]*)$ /find-a-local-doctor/?state=$1&city=$2 [l] 

what want accomplish

change url: http://www.md1network.com/find-a-local-doctor/?state=fl&city=tampa

to this: http://www.md1network.com/find-a-local-doctor/fl/tampa

additionally

since actual file doing work is: http://www.md1network.com/find-a-local-doctor/index.php, need able parse query string php. hopefully, still able state , city.

please help. thanks.

your existing rule looks alright need additional external redirection rule reverse. put rule before existing rule (just below rewritebase /).

# external redirect actual url pretty 1 rewritecond %{the_request} ^[a-z]{3,}\s/+(find-a-local-doctor)/(?:index\.php)?\?state=([^&]+)&city=([^&\s]+) [nc] rewriterule ^ /%1/%2/%3? [r=301,l] 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -