Apache: Rewrite vs Redirect

Apache has two ways to serve one page when you were asked for another: Rewrite* rules via mod_rewrite (e.g. RewriteRule, RewriteCond), and Redirect* rules via mod_alias (e.g. Redirect and RedirectMatch).

What are the differences?

  • mod_rewrite is generally considered the more powerful, and more complex, solution. It offers the RewriteCond directive, which lets you only run a Rewrite rule if certain conditions are met.
  • mod_alias is simpler, and lets you match on a simple string or on a regular expression, but does not allow you to put conditions in (other than those defined by the regexp)

Discussion

Enter your comment
 
server-tech/apache/redirect_vs_rewrite.txt · Last modified: May 24, 2010 01:22 PM by dordal
© 2005-10 David Ordal / DO IT, LLC. All Rights Reserved.