htaccess SSL 重定向

发布于 2024-12-25 20:51:11 字数 317 浏览 1 评论 0原文

我试图仅对几个页面进行 ssl 重定向,例如 viewcart、checkout,当我尝试应用此规则时,它给我服务器 500 错误。

以下是我在 htaccess 中使用的行,

RewriteCond %{HTTPS} on [s=2]
RewriteRule ^viewcart$ https://%{HTTP_HOST}/viewcart [R,L]
RewriteRule ^checkout$ https://%{HTTP_HOST}/checkout [R,L]

提前感谢您的帮助。希望尽快解决。

谢谢 p先生

I am trying to do ssl redirection for few pages only e.g. viewcart, checkout and when I try to apply this rule it gives me server 500 error.

Below is the lines I am using in my htaccess

RewriteCond %{HTTPS} on [s=2]
RewriteRule ^viewcart$ https://%{HTTP_HOST}/viewcart [R,L]
RewriteRule ^checkout$ https://%{HTTP_HOST}/checkout [R,L]

Thanks for help in advance. hope to get it resolved soon.

Thanks
mr p

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不知在何时 2025-01-01 20:51:11

s 不是 RewriteCond 指令的有效标志

[s=2] 上的 RewriteCond %{HTTPS}

您可以通过以下方式实现相同的效果

#if not already https
RewriteCond %{HTTPS} off
RewriteRule ^viewcart$ https://%{HTTP_HOST}/viewcart [R,L]

#if not already https
RewriteCond %{HTTPS} off
RewriteRule ^checkout$ https://%{HTTP_HOST}/checkout [R,L]

s is not a valid flag for the RewriteCond directive

RewriteCond %{HTTPS} on [s=2]

You can achieve the same with below

#if not already https
RewriteCond %{HTTPS} off
RewriteRule ^viewcart$ https://%{HTTP_HOST}/viewcart [R,L]

#if not already https
RewriteCond %{HTTPS} off
RewriteRule ^checkout$ https://%{HTTP_HOST}/checkout [R,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文