Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This is an Apache httpd 2.2 server.

We require that access to this webserver be encrypted by HTTPS.

When web clients visit my site at http://www.example.org/$foo (port 80), I want to redirect their request to the HTTPS encrypted website at https://www.example.org/$foo .

There seem to be two common ways to do this:

First method uses the 'Redirect' directive from mod_alias:

<VirtualHost *:80>
    Redirect permanent / https://www.example.org/
</VirtualHost>

Second method uses mod_rewrite:

<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

What is the difference between a "Redirect permanent" and the mod_rewrite stanza. Is one better then the other?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

By default mod_rewrite does "302 Found" redirects, which are temporary. Assuming everything else is equal, Redirect permanent is equivalent to RewriteRule <blah> [R=permanent].

share|improve this answer

Search engines will see a permanent redirect and update their indexes accordingly.

share|improve this answer

Your Answer

 
discard

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.