【发布时间】:2013-04-09 05:24:24
【问题描述】:
Google 已使用 https 将我网站的主页编入索引。但我只需要将 https 重定向到 http 这个页面。我正在使用 Magento,今天我有一条规则可以删除我域的 htaccess www。我创建的将 https 的主页重定向到 http 的每个规则都不起作用。
有人有解决办法吗?
谢谢
【问题讨论】:
标签: .htaccess http magento https singlepage
Google 已使用 https 将我网站的主页编入索引。但我只需要将 https 重定向到 http 这个页面。我正在使用 Magento,今天我有一条规则可以删除我域的 htaccess www。我创建的将 https 的主页重定向到 http 的每个规则都不起作用。
有人有解决办法吗?
谢谢
【问题讨论】:
标签: .htaccess http magento https singlepage
试试
#Redirect your Homepage from HTTPS to HTTP
RewriteCond %{HTTPS} on
RewriteRule ^$ http://%{HTTP_HOST} [L,R]
见http://www.activo.com/redirect-https-to-http-for-any-homepage/
【讨论】:
首先在 Magento 中进行设置:
打开管理面板并访问 System -> Configration -> Web panel 并设置:
基本 URL(不安全)为 http://www.domain.com/magento/。
基本 URL(安全)为 https://www.domain.com/magento/。
然后设置:
在前端使用安全 URL = 是
保存设置,清除 Magento 缓存
最后在 Magento 的 .htaccess 中将这些行添加到 RewriteBase 行的正下方:
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]
【讨论】:
将此与谷歌索引器的 301 http 请求一起使用。
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
【讨论】:
如果您使用 includeflare,则此重定向不起作用
在您的 htaccess 文件及其 cloudflare 格式上尝试以下内容
Http 到 Https 重定向:
RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
RewriteRule ^(.*)$ https://www.domain.com/$1 [L]
见注释:
在 CloudFlare 中使用灵活 SSL 时,您的源服务器将始终接受通过 HTTP(端口 80)的请求。为了正确重定向通过 HTTPS 安全上网的用户,您应该修改重写规则以使用 CF-Visitor HTTP 标头。 CF-Visitor 标头包含以下内容:
CF-Visitor: {"scheme":"http"}
或
CF 访问者:{"scheme":"https"}
要将用户从 HTTP 重定向到 HTTPS,您可以使用以下命令:
RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
RewriteRule ^(.*)$ https://www.domain.com/$1 [L]
同样,要要求 CloudFlare 上的所有流量都通过 HTTPS,您可以使用以下方法:
RewriteCond %{HTTP:CF-Visitor} !'"scheme":"http"'
RewriteRule ^(.*)$ https://www.domain.com/$1 [L]
【讨论】: