Magento Redirect https to http home page

别来无恙 提交于 2019-12-25 01:54:09

问题


Google has indexed the home page of my website with https. But I need to redirect https to http only this page. I'm using Magento and today I have a rule that removes the htaccess www of my domain. Every rule I created to redirect the main page of https to http didn't work.
Anyone have a solution?
thank you


回答1:


Try

#Redirect your Homepage from HTTPS to HTTP
RewriteCond %{HTTPS} on
RewriteRule ^$ http://%{HTTP_HOST} [L,R]

See http://www.activo.com/redirect-https-to-http-for-any-homepage/




回答2:


Set this up in Magento first:

Oopen admin panel and visit System -> Configration -> Web panel and set:

  • Base URL (unsecured) as http://www.domain.com/magento/.

  • Base URL (secured) as https://www.domain.com/magento/.

then set:

  • Use Secure URLs in Frontend = Yes

  • Save your settings, clear your Magento cache

Finally in Magento's .htaccess add these lines just below RewriteBase line:

RewriteCond %{HTTPS} off
RewriteRule (?!^(index\.php/?|.*\.css|.*\.js|.*\.gif|.*\.jpe?g|.*\.png|.*\.txt|.*\.ico|)$)^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

RewriteCond %{HTTPS} on
RewriteRule ^(index\.php/?|.*\.css|.*\.js|.*\.gif|.*\.jpe?g|.*\.png|.*\.txt|.*\.ico|)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,NC]



回答3:


Use this with 301 http request for google indexer.

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



回答4:


If you use cludeflare then this redirect is not working

place try with below on you htaccess file and it cloudflare format

Http to Https redirection:

 RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
 RewriteRule ^(.*)$ https://www.domain.com/$1 [L]

See note:

When using Flexible SSL with CloudFlare, your origin server will always accept requests over HTTP (port 80). In order to properly redirect a user surfing securely over HTTPS, you should modify your rewrite rules to use the CF-Visitor HTTP header. The CF-Visitor header contains the following:

CF-Visitor: {"scheme":"http"}

or
CF-Visitor: {"scheme":"https"}

To redirect a user from HTTP to HTTPS, you can use the following:

RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
RewriteRule ^(.*)$ https://www.domain.com/$1 [L]

Similarly, to require all traffic go over HTTPS on CloudFlare, you can use the following:

RewriteCond %{HTTP:CF-Visitor} !'"scheme":"http"'
RewriteRule ^(.*)$ https://www.domain.com/$1 [L]


来源:https://stackoverflow.com/questions/16043266/magento-redirect-https-to-http-home-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!