Dear Wiki user, You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.
The following page has been changed by noodl: http://wiki.apache.org/httpd/Rewrite/WhenNotToUseRewrite The comment on the change is: First crack New page: Given the power and flexibility of mod_rewrite it's not surprising that people often use it as their [http://en.wikipedia.org/wiki/Golden_hammer golden hammer]. The following is a list of misuses of mod_rewrite and more appropriate (and often faster) alternatives. === Simple Redirects === {{{ RewriteRule ^/(.*) http://other.example.com/$1 # is better expressed as.. Redirect / http://other.example.com/ }}} === Complex Redirects === {{{ # redirect and drop the trailing uri RewriteRule ^/(.*) http://other.example.com/ # is better expressed as.. RedirectMatch (.*) http://other.example.com/ }}} {{{ # redirect to a uri containing a potion of the original RewriteRule ^/foo/(.+)/bar http://other.example.com/$1 # is better expressed as.. RedirectMatch ^/foo/(.+)/bar http://other.example.com/$1 }}} Valid uses for mod_rewrite when redirect include: * Redirecting based on the query string * Redirecting based on other request details such as user-agents. === Aliasing === {{{ RewriteRule ^/foo/(.*) /bar/$1 # is better expressed as.. Alias /foo /var/www/bar }}} TODO, add AliasMatch examples === Proxying === {{{ RewriteRule ^/(.*) http://other.example.com/$1 [P] # is better expressed as.. ProxyPass / http://other.example.com/ }}} {{{ # reverse proxy everything except images RewriteCond %{REQUEST_URI} !^/images RewriteRule ^/(.*) http://other.example.com/$1 [P] # is better expressed as.. ProxyPass /images ! ProxyPass / http://other.example.com/ }}}
