views:

506

answers:

1

Hi,

I know there is lots of topics regarding my question. I checked them all and tried them out but can't make it work. I need to rewrite http to https on some pages only. After visiting https pages the URL would go back to http. This is what I have so far:


# Rewrite Rules for domain.com
RewriteEngine On
RewriteBase /

#Rewrite www to domain.com
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

#Rewrite to https
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} /secure.php
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]

#traffic to http://, except secure.php
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} /secure.php
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]

When I skip the last set of rules (traffic to http://, except secure.php) the secure.php page loads as https and is encrypted. FINE. With the last set of rules (traffic to http://, except secure.php) the URL rewrites to https, turns blue (SSL) for a second and disappears (no SSL) but the URL is still https.

Any idea? Jacek

A: 

If the URL is still https then it is still using SSL but some of the content on the page probably isn't so it turns off the blue/lock. If you access the page in Internet Explorer you may receive a "page contains secure and nonsecure items" warning. If you get this, you will just need change all content on the page (JavaScript, images, etc.) to load using https or load using a relative path.

Robert