Using .htaccess to control HTTPS on certain pages

*爱你&永不变心* 提交于 2019-12-18 04:09:42

问题


I've got a site that requires (obviously) HTTPS for checkout. The current fix put in place involved making the whole site run in SSL mode, but this is causing problems.

How would I change this...

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]

To only set a certain URL (say basket.php) as HTTPS?


回答1:


I beleive this would work:

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



回答2:


A shorter version:

RewriteCond %{HTTPS} off
RewriteRule ^basket\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [L]


来源:https://stackoverflow.com/questions/1213404/using-htaccess-to-control-https-on-certain-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!