Reputation: 93
I have 3 urls and i want to rewrite :
`health.php?news=apple` to `/health/news/apple`
health.php?info=apple
to /health/info/apple
health.php?articles=apple
to /health/articles/apple
for this i write below given code :
RewriteRule ^health health.php
RewriteRule health/news/(.*) /health.php?news=$1 [NC,QSA]
RewriteRule health/info/(.*) /health.php?info=$1 [NC,QSA]
RewriteRule health/articles/(.*) /health.php?articles=$1 [NC,QSA]
But this isn't working . Please help me.
Thanks in advance.
Upvotes: 0
Views: 67
Reputation: 2019
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^health/(.*)/(.*) health.php?$1=$2
The above code will redirect to health page and then use the first variable as the get variable key and the second one as the value.
Upvotes: 1