0

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.

0

Try this

RewriteCond %{query_string} ^url=(.*)$
RewriteRule ^.*index.php$ /$1? [R=301]
  • Unfortunatelly it doesn't work. It redirects me back to main domain (a.com). – blid Sep 19 '10 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.