Reputation: 107
I have this URL
http://localhost:8888/dochealth/child-doc?cat=doctor
and wanted to replace it with .htaccess REGEX So it becomes
http://localhost:8888/dochealth/child-doc/doctor
so far I have tried this REGEX but it doesn't work
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteRule ^child-doc/([0-9a-zA-Z_-]+) child-doc?cat=$1 [NC,L]
</IfModule>
Upvotes: 2
Views: 48
Reputation: 786091
Have it this way:
Options -MultiViews
RewriteEngine On
RewriteRule ^child-doc/([\w-]+) child-doc.php?cat=$1 [NC,QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
Changes are:
.php
extension handler rule to the bottomchild-doc.php
in other rulesQSA
(query string append) in the same ruleMultiViews
to disable content negotiations service of ApacheUpvotes: 2