Tuesday, January 6, 2009

HTTP TO HTTPS redirect in Apache

Open your httpd.conf file and append the lines given below.

---------------------------------------------------------------
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R,L]
----------------------------------------------------------------

Now restart your apache server.


Below are the link for reference.

http://httpd.apache.org/docs/2.2/misc/rewriteguide.html

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

5 comments:

  1. Can you show me how to refrain one page to redirect. I do not want to redirect one page but all. Thanks for the tip.

    ReplyDelete
  2. Can you show me how to refrain one page to redirect but all. Thanks for the tip.

    ReplyDelete
  3. Hi,
    Can you show me how to refrain one page but all. Thanks for the tip.

    ReplyDelete
  4. Do something like this.

    RewriteRule /pages/mynon-redirectpage.php - [L]

    ReplyDelete