Monday, March 21, 2011

Redirect http requests to https in Apache

Apache HTTP requests can be redirected to HTTPS in many ways. This uses mode_rewrite module to achieve. The configuration can be written in Apache configuration file or htaccess file of an application.

To enable that by using htaccess file, add the lines in to that file. Make sure that mod_rewrite module is enabled with Apache. 

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


No comments:

Post a Comment