在 Magento 中将 HTTPS 重定向到 HTTP,但出现签出异常 (Apache)

发布于 2024-09-14 20:59:52 字数 732 浏览 3 评论 0原文

我正在使用带有一步结账插件的 Magento 安装,这意味着我只有很少的页面需要 HTTPS。我想通过重定向网站的整个 HTTPS 版本来控制 HTTPS 搜索索引和用户访问当然为了安全结账。

安全结帐部分是 /onestepcheckout/ (还包括其中的一些子页面,即 onestepcheckout/failure)。

这是我到目前为止所拥有的,但 HTTPS 并未使用此代码在结账页面上启动,重定向在所有其他情况下都有效(即我将索引 HTTPS 发送到索引 HTTP),只是被破坏的异常:

#Redirect HTTPS to HTTP except checkout 
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^onestepcheckout
RewriteRule ^(.*)$ http://www.mysite.co.uk/$1 [R=301,L]

#Require SSL on checkout
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} ^onestepcheckout\/?$
RewriteRule ^(.*)$ https://www.mysite.co.uk/$1 [R=301,L]

我也模糊地请注意 /onestepcheckout/ 不包含安全资源,因此可能需要将异常添加到图像和样式表等。

I am using a Magento installation with the one step checkout plugin, meaning I have very few pages that need HTTPS. I want to control HTTPS search indexing and user access by redirecting the whole HTTPS version of the site except of course for the secure checkout.

The secure checkout section is /onestepcheckout/ (and also includes some sub pages of that, i.e. onestepcheckout/failure).

This is what I have so far but the HTTPS is not kicking in on the checkout page with this code, the redirect works in all other case (i.e. I send index HTTPS to index HTTP) just the exception that is broken:

#Redirect HTTPS to HTTP except checkout 
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^onestepcheckout
RewriteRule ^(.*)$ http://www.mysite.co.uk/$1 [R=301,L]

#Require SSL on checkout
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} ^onestepcheckout\/?$
RewriteRule ^(.*)$ https://www.mysite.co.uk/$1 [R=301,L]

I am also vaguely cautious that the /onestepcheckout/ does not contain secure resources and therefore an exception may need adding to images and style sheets etc.

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

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

发布评论

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

评论(2

夕嗳→ 2024-09-21 20:59:52

不要忘记,虽然 RewriteRule 中的路径是相对于 .htaccess 文件的上下文进行评估的,但 REQUEST_URI 变量与实际请求相关,因此包含初始斜杠。

所以你需要

RewriteCond %{REQUEST_URI} ^/onestepcheckout\/?$

或者,你可以引用重写规则中捕获的部分:

RewriteCond $1 !^onestepcheckout/

Don't forget that while the paths in the RewriteRule are evaluated relative to the context of the .htaccess file, the REQUEST_URI variable relates back to the actual request and therefore contains the initial slash.

So you need

RewriteCond %{REQUEST_URI} ^/onestepcheckout\/?$

Alternatively, you could refer to the captured part from the rewrite rule:

RewriteCond $1 !^onestepcheckout/
も星光 2024-09-21 20:59:52

试试这个:

    RewriteCond %{REQUEST_URI} onestepcheckout
    RewriteCond %{HTTPS} !off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

Try this :

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