Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Using virtual hosts I have gotten into the habit of using this:

<VirtualHost: *:80>
    Redirect permanent /

Yet I often see rewriting used instead:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

Is there any advantage to one approach over the other?

share|improve this question
up vote 2 down vote accepted

If you don't need mod_rewrite then don't use it. For simple cases like this mod_alias is perfectly sufficient, and much simpler to understand. Also, while minor, mod_alias is faster than mod_rewrite -- this can make a difference on high volume sites.

share|improve this answer

Those two directive result in the same 301 code being sent back to the browser. So no advantage to one or the other. You should choose one based on whichever you are more comfortable using and makes reading the configuration file easier.

Both are capable of also sending something other than the 301 (Permanent Redirect) code. You should always use a 301 when eliminating (or requiring) the "www" for clarity to SEO and browsers. The other types of redirects are used less commonly (very infrequently); a "temporary redirect" is the most common of them, and should only be used when the destination of the redirect will change often (for example, a link your most recent blog entry or something like that).

share|improve this answer

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.