Mod Rewrite noob so pardon my ignorance but all I am trying to do is a simple query string removal
from: http://yourwebsite.com/x?section=y
to: http://yourwebsite.com/x/y
I am adding my mod rewrite rules in my .htaccess like this:
ErrorDocument 404 /404
Options +MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{QUERY_STRING} ^section=(.*)$ [NC]
RewriteRule ^(.*)$ /$1/%1? [R=301,L,NE]
The problem is that on visiting:
http://yourwebsite.com/x?section=y
My rule writes it back as:
http://yourwebsite.com/x.php/y
That .php in the pretty url is pretty darn ugly and I am struggling to get rid of it.
What is wrong in my mod rewrite rule?
x.phpexists, so the firstRewriteRulematches and rewrites the request tox.php. Just as you configured it to do. So what is it you want to do instead?x.phpexists. It can be visited byhttp://yourwebsite.com/x. I want urls likehttp://yourwebsite.com/x?section=yto rewrite tohttp://yourwebsite.com/x/y. Currently, they are rewritten ashttp://yourwebsite.com/x.php/y