Posts Tagged ‘.htaccess’

Rewrites – http and https

No Comments »

If you are using https, then you may need to make some changes to your .htaccess code.   If you are doing rewrites that use the full URL (for example and you will be switching between http and https, then you will need to add a RewriteCond to your code.   You will need to test for https and code the full URL accordingly (using http or https).   The following examples show how to test for https or the lack of https.

RewriteCond %{HTTPS} on
RewriteCond %{HTTPS} !=on

For example, if you want to force all requests to your site to use https, you could use the following:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]