Switching between HTTP and HTTPS

From Joomla! Documentation

Documentation all together tranparent small.png
Under Construction

This article or section is in the process of an expansion or major restructuring. You are welcome to assist in its construction by editing it as well. If this article or section has not been edited in several days, please remove this template.
This article was last edited by Sdwdeiahil (talk| contribs) 2 months ago. (Purge)

This Article Needs Your Help

This article is tagged because it NEEDS REVIEW. You can help the Joomla! Documentation Wiki by contributing to it.
More pages that need help similar to this one are here. NOTE-If you feel the need is satistified, please remove this notice.

For setting up the certificate, the simplest way is to get your host to do it for you. Once you've bought a Dedicated IP and SSL certificate, simply ask your host to help and they will get it signed and install it in the correct location for you. Once it's done, you should be able to manually enter HTTP or HTTPS on any page.

If you're also asking how to automatically switch between HTTP and HTTPS depending on which page you're on, most of the work is done for you if you set your SECUREURL correctly in your configuration (i.e. set to https://yourdomain.com). If you have other pages on your site that you want to be secured (as I do), then you can handle these through your .htaccess. As an example, to switch from HTTP to HTTPS on any page that has 'abc/def' or 'ghi' in the URL, add something like this:


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:


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 you can insert the code below into a .htaccess file placed in that specific folder:


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.