1

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 ^(.*)$ http://domainname.com/$1 [R=301,L]
</IfModule>

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

<IfModule mod_alias.c>
  Redirect permanent / http://domainname.com/
</IfModule>

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

its_me
  • 225
  • 1
  • 7
  • 23

1 Answers1

2

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

  • 2
    I don't know about specific performance benchmarks... But the apache folks make the recommended (redirect > rewrite) approach quite clear: http://httpd.apache.org/docs/2.2/rewrite/avoid.html#redirect – Daniel Widrick Sep 23 '13 at 07:53