Jump to content
Sign in to follow this  

Default HTTPS

Recommended Posts

If anyone ever asks, you can force HTTPS for any http links by editing your .htaccess files for said domains.

I just turned this on today, as I was prior pointing the configurations to use https.  If you run into any snags with the http rewrite rule, drop me a line and let me know.


RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

is what I have in the .htaccess for handling the HTTPS defaulting.

The [L] flag is short for Last and the [R] is for Redirection.  Per the Apache docs, the Last says the redirect is only applicable to the current url, as to not break sequential links.
The 301 is saying this is a permanent redirect, in web server language.  It's pretty funny that searching for my nickname, only shows FTB at the bottom of the 1st page on a google search.

Share this post

Link to post

If you use cpanel issued certs, the rewrite rule will break the auto-renew cert process, since it uses a non-https link to validate the reissued cert.
Only nuance at this point from the .htaccess rule.

Share this post

Link to post
Sign in to follow this