Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

http://host/stories/2001/another-stories?id=2000

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

how can i remove it?

many thanks!

share|improve this question

1 Answer 1

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

 
discard

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.