Rewrites and https

Web programming topics
Post Reply
Tony
Lieutenant
Lieutenant
Posts: 86
Joined: Tue Jul 21, 2009 4:11 pm

Rewrites and https

Post by Tony » Sat Nov 28, 2009 6:16 pm

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 https://robot.lk/page.htm) 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.

Code: Select all

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:

Code: Select all

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

Return to “Web programming”