Two ways to force SSL on your website

Two solutions, both to be put in the .htaccess file, when you want to force your website visitors to go through SSL:

Solution A:

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

Solution B:

RewriteEngine on
RewriteCond %{HTTPS} !^on$ [NC]
RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI} [L]

Pick whatever solution looks nicer for you.

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <center> <hr>
  • Lines and paragraphs break automatically.
  • Use the special tag [adsense:format:group:channel] or [adsense:block:location] to display Google AdSense ads.
  • Images can be added to this post.

More information about formatting options

1 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.