.htaccess redirect for both canonical https:// and www
I'm hoping that Apache .htaccess script counts as a programming language here. ;-)
I'm currently converting a site to the canonical form https://www.example.com and thus would like to place the relevant code in the site's root .htaccess file to redirect accordingly. The code I've come up with so far is: Code:
RewriteCond %{HTTPS} !=on Does anybody know of any way of doing this so that there is a maximum of only one redirect? |
Quote:
By the way, these configurations should not go in .htaccess unless you don't have access to the vhost's own configuration files. The .htaccess is a work-around for situations where you don't have access to the configuration files themselves. I'm not sure why so many guides out there still mention .htaccess since separate configuration files for the vhosts have been around since the 90's. |
Quote:
The site's on a shared hosting, hence the use of .htaccess. |
The solution in the end was quite simple. Thanks to Turbocapitalist for the inspiration.
Code:
RewriteEngine On |
All times are GMT -5. The time now is 11:30 PM. |