问题
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