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
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
Now this does the trick. However, it requires a maximum of two 301 redirects before the url attains its canonical form.
Does anybody know of any way of doing this so that there is a maximum of only one redirect?