Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.
RewriteRule ^([^/]*)/([^/]*)$ /index.php?id=$1&n=$2 [L]

  This rule will write to


How can I add/change the rule to stop calls to from rewriting?



Per Shane's comment, and looking closer at the regex:

RewriteRule ^([^/]*)/([^/]*)$ /index.php?id=$1&n=$2 [L]

1 First Expression


^   = start string
( ) = group
[ ] = match
^   = not "/"
*   = 0 or more of the preceding

2 slash /

3 Repeat previous expression ([^/]*)

4 end string $

So to keep /blog/ from rewriting: match lowercase letters in the first expression [a-z]

Final Rule

RewriteRule ^([^/a-z]*)/([^/]*)$ /index.php?id=$1&n=$2 [L]
share|improve this question
Is that the only thing that you ever want to avoid rewriting? Or, do you have some specific rules around things that should be rewritten (like those where the 'id' is a number)? – Shane Madden Oct 8 '12 at 4:14
At the moment, it should allow php files in the /blog/ directory. – rrrfusco Oct 8 '12 at 4:16

1 Answer 1

up vote 0 down vote accepted

Add a rule before your current one that will prevent rewriting the files that you want to leave alone.

RewriteRule ^blog/.*\.php$ - [L]
RewriteRule ^([^/]*)/([^/]*)$ /index.php?id=$1&n=$2 [L]
share|improve this answer
Your answer looks good too. See mine above. – rrrfusco Oct 8 '12 at 4:54

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.