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've got this sample rule:

RewriteRule ^stories\/([0-9]+)\/(.*)+ stories/index.cfm?id=$1

and this works perfect.

now, i would redirect one page (just rewrited) to another:

Redirect 301 /stories/2000/title-of-stories http://host/stories/2001/another-stories

but apache redirect to


appending to url the query string "?id=2000"

how can i remove it?

many thanks!

share|improve this question
up vote 1 down vote accepted

Your problem is that the RewriteRule is being applied after the Redirect.

Best practice is not to mix directives from the mod_rewrite (RewriteRule) and mod_alias (Redirect). The order in which they are applied is not based on the order that your write the rules, but on the order that the modules are loaded.

In this case, replacing the Redirect 301 directive with an equivalent RewriteRule would be the best option. I haven't tested this, but something like this might work for you. Note, that you should put your most specific rule first:

RewriteRule ^/stories/2000/title-of-stories$ /stories/2001/another-stories [L,R=301]
RewriteRule ^/stories/([0-9]+)/(.*)+ /stories/index.cfm?id=$1 [L]
share|improve this answer
barryj, this it's simply ingenious :-) works great! many thanks :-) – Roberto Jun 5 '11 at 22:34
@Roberto, glad that works for you - you might mark my answer correct. – barryj Jun 6 '11 at 7:26
done :-) – Roberto Jun 15 '11 at 5:27

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.