Enabling HTTPS on your site: Difference between revisions
From Joomla! Documentation
Blancanieve (talk | contribs) took out references to Chrome, since this is true for the majority of browsers |
Some markup and phrasing changes. |
||
Line 5: | Line 5: | ||
<translate> | <translate> | ||
<!--T:2--> | <!--T:2--> | ||
Transport Layer Security (TLS) is the successor to Secure Sockets Layer (SSL) - although | Transport Layer Security (TLS) is the successor to Secure Sockets Layer (SSL) - although many people still refer to it as SSL.</translate> | ||
<translate> | <translate> | ||
<!--T:3--> | <!--T:3--> | ||
Have you ever noticed the lock icon next to the URL when browsing the internet? That means that all the data you send to that website is being sent encrypted so anyone who may have hacked your network (or similar) and can intercept your requests is unable to view any of the data - they can only see what URLs you are accessing.</translate> | |||
<translate> | <translate> | ||
Line 14: | Line 14: | ||
<translate> | <translate> | ||
<!--T:5--> | <!--T:5--> | ||
Google (and most other search engines) now treat sites using https with preference<ref>https://webmasters.googleblog.com/2014/08/https-as-ranking-signal.html</ref>. Furthermore many browsers flag any website with a form (such as a login or contact form) that isn't using https<ref>https://www.blog.google/products/chrome/milestone-chrome-security-marking-http-not-secure/</ref></translate> | Google (and most other search engines) now treat sites using ''https'' with preference<ref>https://webmasters.googleblog.com/2014/08/https-as-ranking-signal.html</ref>. Furthermore many browsers flag any website with a form (such as a login or contact form) that isn't using ''https''<ref>https://www.blog.google/products/chrome/milestone-chrome-security-marking-http-not-secure/</ref></translate> | ||
<translate> | <translate> | ||
== How | == How Do I Setup TLS? == <!--T:6--></translate> | ||
<translate> | <translate> | ||
<!--T:7--> | <!--T:7--> | ||
To set up the certificate, the simplest way is to get your host to do it for you.</translate> | |||
<translate> | <translate> | ||
<!--T:8--> | <!--T:8--> | ||
The correct certificate to | The correct certificate to use depends on the security protections required on your website. The least expensive and easiest option is to use [https://letsencrypt.org/ Let's Encrypt] - it's free and, depending on your host, can be often be configured straight from your cPanel or Plesk hosting dashboard.</translate> | ||
<translate> | <translate> | ||
<!--T:9--> | <!--T:9--> | ||
If you've | If you've purchased a Dedicated IP and SSL certificate, ask your host to help and they will get it signed and install it in the correct location for you.</translate> | ||
<translate> | <translate> | ||
== How | == How Do I Redirect All Traffic to ''https'' == <!--T:10--></translate> | ||
<translate> | <translate> | ||
=== In Joomla === <!--T:11--></translate> | === In Joomla === <!--T:11--></translate> | ||
<translate> | <translate> | ||
<!--T:12--> | <!--T:12--> | ||
The easiest way to enforce https traffic is to do it within Joomla. In Global Configuration there is a | The easiest way to enforce ''https'' traffic is to do it within Joomla. In the Global Configuration there is a ''Force HTTPS'' option that allows you to force HTTPS either in the Administrator only or for the entire site. Prefer the latter.</translate> | ||
[[Image:Enable_HTTPS_In_Global_Config-<translate><!--T:13--> en</translate>.png|800px|center|Image Showing the Force HTTPS option in the Joomla 3.x default backend template]] | [[Image:Enable_HTTPS_In_Global_Config-<translate><!--T:13--> en</translate>.png|800px|center|Image Showing the Force HTTPS option in the Joomla 3.x default backend template]] | ||
<translate> | <translate> | ||
=== In .htaccess === <!--T:14--></translate> | === In ''.htaccess'' === <!--T:14--></translate> | ||
< | <syntaxhighlight lang="apache"> | ||
RewriteEngine on | RewriteEngine on | ||
RewriteCond %{SERVER_PORT} !^443$ | RewriteCond %{SERVER_PORT} !^443$ | ||
Line 49: | Line 49: | ||
Redirect permanent / https://www.yourdomainname.com | Redirect permanent / https://www.yourdomainname.com | ||
</IfModule> | </IfModule> | ||
</ | </syntaxhighlight> | ||
<translate> | <translate> | ||
==== More | ==== More Complex ''.htaccess'' Examples ==== <!--T:15--></translate> | ||
<translate> | <translate> | ||
<!--T:16--> | <!--T:16--> | ||
To switch from HTTP to HTTPS on any page that has 'abc/def' or 'ghi' in the URL, add something like this: | |||
<!--T:17--> | <!--T:17--> | ||
Code:</translate> | Code:</translate> | ||
< | <syntaxhighlight lang="apache">RewriteCond %{HTTPS} off | ||
RewriteRule ^(abc/def|ghi)(.*)/?$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]</ | RewriteRule ^(abc/def|ghi)(.*)/?$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]</syntaxhighlight> | ||
<translate> | <translate> | ||
<!--T:18--> | <!--T:18--> | ||
... and to switch from HTTPS back to HTTP on any page that has 'home' or 'help' in the URL, do something like this: | ...and to switch from HTTPS back to HTTP on any page that has 'home' or 'help' in the URL, do something like this: | ||
<!--T:19--> | <!--T:19--> | ||
Code:</translate> | Code:</translate> | ||
< | <syntaxhighlight lang="apache"> | ||
RewriteCond %{HTTPS} on | RewriteCond %{HTTPS} on | ||
RewriteRule ^(home|help)(.*)/?$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]</ | RewriteRule ^(home|help)(.*)/?$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]</syntaxhighlight> | ||
<translate> | <translate> | ||
<!--T:20--> | <!--T:20--> | ||
If you want to force SSL on a specific folder | If you want to force SSL on a specific folder, insert the code below into an ''.htaccess'' file placed in that specific folder: | ||
<!--T:21--> | <!--T:21--> | ||
Code:</translate> | Code:</translate> | ||
< | <syntaxhighlight lang="apache"> | ||
RewriteEngine On | RewriteEngine On | ||
RewriteCond %{REQUEST_URI} folder | RewriteCond %{REQUEST_URI} folder | ||
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]</ | RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]</syntaxhighlight> | ||
<translate> | <translate> | ||
<!--T:22--> | <!--T:22--> | ||
Make sure you change the folder reference to the actual folder name. Then be sure to replace www.example.com/folder with your actual domain name and folder you want to force the SSL on.</translate> | Make sure you change the folder reference to the actual folder name. Then be sure to replace ''www.example.com/folder'' with your actual domain name and folder you want to force the SSL on.</translate> | ||
<noinclude> | <noinclude> |
Latest revision as of 00:05, 10 November 2022
|
What is SSL/TLS?
Transport Layer Security (TLS) is the successor to Secure Sockets Layer (SSL) - although many people still refer to it as SSL. Have you ever noticed the lock icon next to the URL when browsing the internet? That means that all the data you send to that website is being sent encrypted so anyone who may have hacked your network (or similar) and can intercept your requests is unable to view any of the data - they can only see what URLs you are accessing.
Why Use TLS?
Google (and most other search engines) now treat sites using https with preference[1]. Furthermore many browsers flag any website with a form (such as a login or contact form) that isn't using https[2]
How Do I Setup TLS?
To set up the certificate, the simplest way is to get your host to do it for you.
The correct certificate to use depends on the security protections required on your website. The least expensive and easiest option is to use Let's Encrypt - it's free and, depending on your host, can be often be configured straight from your cPanel or Plesk hosting dashboard.
If you've purchased a Dedicated IP and SSL certificate, ask your host to help and they will get it signed and install it in the correct location for you.
How Do I Redirect All Traffic to https
In Joomla
The easiest way to enforce https traffic is to do it within Joomla. In the Global Configuration there is a Force HTTPS option that allows you to force HTTPS either in the Administrator only or for the entire site. Prefer the latter.

In .htaccess
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [QSA,R=301,L]
<IfModule !mod_ssl.c>
Redirect permanent / https://www.yourdomainname.com
</IfModule>
More Complex .htaccess Examples
To switch from HTTP to HTTPS on any page that has 'abc/def' or 'ghi' in the URL, add something like this:
Code:
RewriteCond %{HTTPS} off
RewriteRule ^(abc/def|ghi)(.*)/?$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]
...and to switch from HTTPS back to HTTP on any page that has 'home' or 'help' in the URL, do something like this:
Code:
RewriteCond %{HTTPS} on
RewriteRule ^(home|help)(.*)/?$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]
If you want to force SSL on a specific folder, insert the code below into an .htaccess file placed in that specific folder:
Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]
Make sure you change the folder reference to the actual folder name. Then be sure to replace www.example.com/folder with your actual domain name and folder you want to force the SSL on.