Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 want to redirect all requests for NOT(main.php) to handelrequest.php?page=[page]
So it must be something like:

RewriteRule !(main.php) handlerequest.php?page=$1


RedirectMatch !(main.php) handlerequest.php?page=$1

but it seems, that those modules haven't negation at all...

May be it is possible to combine it. Some thing like:

RewriteRule (main.php\?.*) $1
RewriteRule (*) handlerequest.php?page=$1

If not main.php, else for all others the second rule become active.
Is there some solution?

Thank you for ahead.

share|improve this question
up vote 1 down vote accepted
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !main.php
RewriteRule ^(.*)$ handlerequest.php?page=$1

That says.. if the requested filename is main.php don't run the rule.. for everything else run the rule.

share|improve this answer
Thank you very much, it work!!! :) – Rodnower Nov 29 '10 at 13:00
It is also possible to add $ to !main.php to be more exact. – Rodnower Nov 29 '10 at 13:01

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.