简体   繁体   English

Magento - 需要对两个页面强制使用 HTTP,网站的其余部分强制使用 HTTPS

[英]Magento - Need to force HTTP for two pages, and the rest of the website forced to HTTPS

I have seen a couple of other people, also asked this question.我见过其他几个人,也问过这个问题。 I did not find any solution working out for me though.不过,我没有找到任何适合我的解决方案。 So here is my problem:所以这是我的问题:

On my Magento installation, HTTPS is forced for all pages, for security reasons.在我的 Magento 安装中,出于安全原因,所有页面都强制使用 HTTPS。 I wish to exclude two pages from this, so they are HTTP.我希望从中排除两个页面,因此它们是 HTTP。 It's two API PHP script/pages.这是两个 API PHP 脚本/页面。

I'm quite lost at this point, but I hope someone will know more about this than me.在这一点上我很迷茫,但我希望有人比我更了解这一点。 I tried a couple of things in the .htaccess file, but no success.我在.htaccess文件中尝试了一些东西,但没有成功。 I really hope one of you guys can help me out!我真的希望你们中的一位能帮助我!

This forces everything to HTTPs except for the directories that you specify within the brackets:除了您在括号中指定的目录外,这会将所有内容强制为 HTTPS:

RewriteEngine On

#Force everything to HTTPs
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]

#Checks if HTTPs is on for foobar & foobar2, if it is, turn it off
RewriteCond %{HTTP:X-Forwarded-SSL} =on
RewriteCond %{REQUEST_URI} !^\/(foobar|foobar2)
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301]

Replace foobar & foobar2 etc with the directories you wish to exclude.将 foobar 和 foobar2 等替换为您希望排除的目录。 However, if your magneto installation already forces everything to HTTPs, then you only need the second part of this Rewrite:但是,如果您的磁电机安装已经将所有内容强制为 HTTP,那么您只需要重写的第二部分:

#Checks if HTTPs is on for foobar & foobar2, if it is, turn it off
RewriteCond %{HTTP:X-Forwarded-SSL} =on
RewriteCond %{REQUEST_URI} !^\/(foobar|foobar2)
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM