16 Jan 2010

force http to https

htaccess No Comments

Sometimes you may need to force your website visitors to browse your site over a secure SSL connection.
An easy to way to always redirect the user to secure connection. (https://) can be accomplished with a .htaccess file containing the following lines:

In this example I have used bizante.com but you can change to your own website

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.bizante.com/$1 [R,L]

Please, note that the .htaccess should be located in the web site’s root folder.

In case you wish to force HTTPS for a particular folder you can use:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} somefolder RewriteRule ^(.*)$ https://www.bizante.com/somefolder/$1 [R,L]

In this case the .htaccess file should go in the folder you wish to redirect.

No Responses to “force http to https”

Leave a Reply