UnixServerAdmin

Server Administration & Management

How to Redirect from http to https using .htaccess

If  SSL  is installed on the server and you want redirect all requests to https then you need to add the following code in .htaccess file.

===========================================================
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
===========================================================

OR

=============================================
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://www.domain.com [L,R]
=============================================

Advertisements

March 11, 2011 Posted by | Apache, htaccess | , , | 3 Comments