在 Magento 中将 HTTPS 重定向到 HTTP,但出现签出异常 (Apache)
我正在使用带有一步结账插件的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要忘记,虽然 RewriteRule 中的路径是相对于 .htaccess 文件的上下文进行评估的,但 REQUEST_URI 变量与实际请求相关,因此包含初始斜杠。
所以你需要
或者,你可以引用重写规则中捕获的部分:
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
Alternatively, you could refer to the captured part from the rewrite rule:
试试这个:
Try this :