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 »

  1. Thanks a ton for bothering to line this all out for us. This kind of post was really helpful in my opinion.

    Comment by Daniel Noblet | June 15, 2011 | Reply

  2. Your ability to write about this specific information is precisely what all of us want. By discussing your knowledge you help other people thru expressing your very own information. And I’ll tell you right now your writing aided me.

    Comment by fresh water | June 15, 2011 | Reply

  3. Many thanks for disclosing this article. I believe that it is extremely valuable and will share it to associates, as well. If you carry on publishing concerning this subject I definitely will keep on browsing your future blog posts.

    Comment by amazing water blog | June 16, 2011 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: