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 came across an article titled "Efficient 301 Redirects."

For example, if you are trying to redirect your site from www to non-www domain, the article suggests that when compared to this .htaccess/httpd.conf rule:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^www.domainname\.com$ [NC]
  RewriteRule ^(.*)$$1 [R=301,L]

this would be a more efficient 301 redirect (although only slightly):

<IfModule mod_alias.c>
  Redirect permanent /

Question: Is the latter rule really efficient (even slightly)?

share|improve this question
Indeed. However, I'm unsure why you can't simply add the second rule after enabling mod_alias. – Pothi Sep 22 '13 at 2:16
up vote 2 down vote accepted

to answer your question: yes, it is, and the article also states why:

... by using Redirect directive of Apache and return directive of Nginx, we can effectively avoid doing any capturing or matching at all and thus we can completely avoid evaluation of a regular expression.

it's about simply skipping some steps of evaluation.

i'd like to see perftest against this solution/tweaks

share|improve this answer
I don't know about specific performance benchmarks... But the apache folks make the recommended (redirect > rewrite) approach quite clear: – Daniel Widrick Sep 23 '13 at 7:53

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.