2014-11-20 63 views
0

我一直无法找到如何仅将https域版本的根域重定向到http版本的答案,并且保持子页面和子文件夹不变。301使用modrewrite在htaccess中重定向根URL https到http

例如,我想

[this is not a link]https://www.domain.com to point to http://www.domain.com 
[this is not a link]https://www.domain.com/ to point to http://www.domain.com 

我采取了多种其他重写规则,但无法弄清楚如何实现这一目标。

回答

0

您可以在DOCUMENT_ROOT/.htaccess文件中使用此代码:

RewriteEngine On 
RewriteBase/

RewriteCond %{HTTPS} on 
RewriteRule ^/?$ http://%{HTTP_HOST}/ [L,R=302] 
+0

确实的RewriteCond每次都重写规则发生之前需要申报? – 123cctv 2014-11-20 22:44:29

+0

并不总是如此,因为它确保我们从'https => http'重定向 – anubhava 2014-11-20 22:46:55

+1

感谢它的工作。 – 123cctv 2014-11-20 22:48:36