Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this htaccess rule

RewriteCond %{REMOTE_ADDR} ^xxx\.xxx\.xxx\.xxx
RewriteCond %{REQUEST_URI} !/path/to/file.php$
RewriteRule $ /path/to/file.php [R=302,L]

and the purpose to is redirect a specific IP who visits any page to one page in particular /path/to/file.php

This is working for URLs which have spaces in them. But it is not working for URLs which contain %20 instead of spaces, and URLs which have no spaces. Where have I gone wrong with this?

share|improve this question

I think if you change this line:

RewriteRule $ /path/to/file.php [R=302,L]

to this:

RewriteRule ^(.*)$ /path/to/file.php [R=302,L]

you will be good to go. Make sure you clear your browser cache when you test redirects.

share|improve this answer

Your Answer


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.