Lindy
Lindy

Reputation: 3

Htaccess http to https with php exception

I recently changed my website to https and I used an .htaccess re-write to send everything via https using this...

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

However one page (contact-us.php) is throwing up https errors on a couple of browsers (IE and Chrome) which I looked into fixing but they're tough. The easiest work around for me would be make the offending page (contact-us.php) an exception to the global http to https rule. But how?!

Thanks in advance for any replies.

Upvotes: 0

Views: 880

Answers (1)

Croises
Croises

Reputation: 18671

You can use that :

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/contact-us\.php [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]

RewriteCond %{HTTPS} on
RewriteRule ^contact-us\.php http://%{HTTP_HOST}/contact-us.php [NC,L,R=302]

Upvotes: 2

Related Questions