mod_rewrite vs mod_alias

Discuss practical ways rearrange URLs using mod_rewrite.

mod_rewrite vs mod_alias

Postby chadm » Tue Aug 12, 2008 10:31 am

Who gets priority?

I have inherited an apache instance that has RedirectPermanent() and RedirectMatch() statements all over the http.conf file.

When I try to add several RewriteCond () leading up to a RewriteRule, the site breaks pretty terribly!

What's the precedence; mod_rewrite or mod_alias? Which statements should come first in the .conf file?

Should I use one or the other and not both?

Thanks for any guidance!
chadm
 
Posts: 2
Joined: Tue Aug 12, 2008 10:25 am

Postby richardk » Wed Aug 13, 2008 1:28 pm

If they are both redirecting (302 or 301), the first RewriteRule or Redirect will take precedence.

If there is a RewriteRule rewriting the Redirect will take precedence.

On my test server at least.

What are you Redirects and mod_rewrite?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

we obviously have some conflicting rules.

Postby chadm » Thu Aug 14, 2008 1:29 pm

I will post some code after I can strip out some of our "secret" stuff. I think I'm going to bite the bullet and convert everything to rewrite rules and skip the redirectmatch() statements.

For some clarity..

rewriteCond(1)
rewriteCond(2)

rewriteRule(); ## if this one executes, everything else stops...

rewriteCond(3)
rewriteCond(4)
rewriteRule(); ## this is the last rule which uses cond 3&4 (Not conds 1&2)

redirectmatch(); ## this will only execute if both rewriterules "fail" or "pass through"

Thanks for the help!
chadm
 
Posts: 2
Joined: Tue Aug 12, 2008 10:25 am

Postby richardk » Sat Aug 16, 2008 4:08 pm

For some clarity..

rewriteCond(1)
rewriteCond(2)

rewriteRule(); ## if this one executes, everything else stops...

rewriteCond(3)
rewriteCond(4)
rewriteRule(); ## this is the last rule which uses cond 3&4 (Not conds 1&2)

redirectmatch(); ## this will only execute if both rewriterules "fail" or "pass through"

It depends. If the RewriteRules do a redirect (the user's browser address bar changes) then that is where it stops. If it does an internal redirect the RedirectMatch may run.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron