简体   繁体   中英

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. I wish to exclude two pages from this, so they are HTTP. It's two API PHP script/pages.

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. 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:

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. However, if your magneto installation already forces everything to HTTPs, then you only need the second part of this Rewrite:

#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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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