So i have a htaccess rewrite that makes a query string to a path like so..
RewriteRule ^page/(.*)$ page.php?query=$1
This works fine and using the above i can access the page via both page.php?query= and /page/query/ but how can i make it so that if the page is accessed by the page.php?query= method, it automatically redirects to the path version?
I’ve tried the following but i don’t think i wrote it correctly…
RewriteCond %{HTTP_HOST} ^www.webaddress.com/page.php?query=$
RewriteRule ^(.*)$ http://www.webaddress.com/page/$1 [R=301,L]
Any help to fix this would be appreciated. Thanks.
2
Answers
Try it before your internal rewrite rule.
You can use the following