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 a site with this existing rule:

RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

so that it captures all URLs and translates them to this query.

How can I precede this with something that will make an exception for URLs of the form{anything}

e.g. any URL that refers to something in a /services directory?

share|improve this question
up vote 4 down vote accepted


RewriteCond %{REQUEST_URI} !/services

If you are putting this into .htaccess, you might need:

RewriteCond %{REQUEST_URI} !services


RewriteCond %{REQUEST_URI} !services/
share|improve this answer
is /services a regexp? do I need the ^ in front of it? – Jason S Dec 1 '09 at 2:30
Quite possibly it is. Try it with and without a ^ and see which works best. Also see the full docs on which is for apache 2.0 and probably hasn't changed recently. – Michael Graff Dec 1 '09 at 2:33

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.