Commentary and OpinionsRamblings and Rants

 


Call Toll Free 855-927-7583
Email:
Get vCard

While I was working on a small project to add LetsEncrypt to a shared hosting site, I had to do a few things to make sure the .htaccess file worked with the Joomla directories to use the certificate correctly. If a user types 'TheirDomain.com', you want them to go to 'https://www.TheirDomain.com'. To make this happen, edit the .htaccess file in the root directory and add the following after "RewriteEngine On"

# redirect to www
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# redirect to https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

This redirects the user to the 'www' site regardless of whether they are using http or https. Once the server has that correct, it enforces the https connection in the second rewrite condition.

Enjoy.

Search the Blog

Login Form

Who's Online

We have 11 guests and no members online

Join Our Newsletter

Get Updates, Upcoming Themes Info, and Our Great Deals!
Provided by FeedBurner at Google.

Login Form