Knowledgebase: Certificates
Force HTTPS on Apache 2
If you would like to force the entire site to use SSL:

          RewriteEngine On
          RewriteCond %{HTTPS} !=on
          RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]

Alternatively, you may use an .htaccess file(or inside a <Directory> block):

          RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]

Note: Take note this method is missing leading slash ( / ).

There are some instances where one would like to force HTTPS on a sub-domain/sub-directory:

          RewriteEngine On
          RewriteCond %{HTTPS} !=on
          RewriteRule ^/secure(.*) https://%{SERVER_NAME}/secure$1 [R,L]

.htaccess entry

          RewriteRule ^secure(.*) https://%{SERVER_NAME}/secure$1 [R,L]

Note: Where secure is the sub-domain to secure.
(841 vote(s))
Not helpful

Comments (0)