[英]Codeigniter: Check and force one page to https://
我希望我的大多数网站都是http://但是对于单个结帐页面是https://
如何检查并将用户切换到https://因此他们无法将其与http://一起使用?
您可以使用.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]
希望它也适合你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.