【发布时间】:2013-06-24 09:00:16
【问题描述】:
我希望我的大部分网站都是 http:// 但单个结帐页面是 https://
如何检查用户并将其切换到 https://,这样他们就没有机会将其与 http:// 一起使用?
【问题讨论】:
标签: php codeigniter .htaccess redirect https
我希望我的大部分网站都是 http:// 但单个结帐页面是 https://
如何检查用户并将其切换到 https://,这样他们就没有机会将其与 http:// 一起使用?
【问题讨论】:
标签: php codeigniter .htaccess redirect https
您可以使用 .htaccess 规则对特定 URL 强制使用 SSL。在此示例中,如果有人访问任何注册/付款目录,他们将被重定向到 https:// URL。
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteCond $1 ^(register/payment|login)
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} 443
RewriteCond $1 !^(register/payment|images|css|javascript|login)
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
您可以根据需要更改此设置。希望这会有所帮助。
【讨论】:
您可以通过这种方式进行测试,并且对我来说效果很好
将此代码添加到您的 .htaccess 文件中
RewriteEngine On
RewriteCond %{HTTPS} !^on$
RewriteRule ^checkout ? https://myproject.localhost/my_checkout_url [R,L]
希望它也适合你
【讨论】: