mod_rewrite, 301 problem
- by blid
Hi,
Currently I can access specific site in two ways:
1. http://a.com/foo/bar
2. http://a.com/index.php?url=foo/bar
What I'm trying to achive is to allow to do it only using first way, and make redirect 301 on the second to the first one. Here's the code which I made so far and put into .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
#tricky part
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?url=?(.*)\ HTTP/
RewriteRule ^index\.php$ http://a.com/$1 [R=301,L]
</IfModule>
Currently it do almost all the job, it's redirecting index.php to /, but index.php?url=foo/bar to /?url=foo/bar and I can't manage to make it right. TIA.