简体   繁体   中英

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.

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM