Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

Try this

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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