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


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

1 Answer 1



RewriteCond %{REQUEST_URI} !/services

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

RewriteCond %{REQUEST_URI} !services


RewriteCond %{REQUEST_URI} !services/
  • is /services a regexp? do I need the ^ in front of it?
    – Jason S
    Dec 1, 2009 at 2:30
  • Quite possibly it is. Try it with and without a ^ and see which works best. Also see the full docs on httpd.apache.org/docs/2.0/mod/mod_rewrite.html which is for apache 2.0 and probably hasn't changed recently. Dec 1, 2009 at 2:33
  • 12 years later & still a sound working solution! I did not need to use a ^.
    – n8bar
    Nov 29, 2021 at 18:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .