Thursday, April 19, 2007

Apache Http to Https

I wanted to redirect all the http requests coming to Apache web server to https requests. I found a simple solution to do that. This method may not be the ideal way for that but it worked for me.

first make sure that /etc/httpd/conf/httpd.conf contains the following line

LoadModule rewrite_module modules/mod_rewrite.so

Then add following lines to httpd.conf
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*)$ https://www.foo.com/$1 [L,R]

finally restart the apache using
service httpd restart

last but not least test it using http://www.your.domain.com/
then you will see https://www.your.domain.com/

hope this method works for all...............


No comments: