简体   繁体   English

301使用modrewrite将根URL https重定向到htaccess中的http

[英]301 Redirect Root URL https to http in htaccess using modrewrite

I have been unable to find an answer to how to redirect only the https version of the root domain to the http version, and leave the subpages and subfolders untouched. 我一直无法找到有关如何仅将根域的https版本重定向到http版本,并使子页面和子文件夹保持不变的答案。

For example, I would like 例如,我想

[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

I have several other rewrite rules in place, but unable to figure out how to achieve this. 我还有其他一些重写规则,但是无法弄清楚如何实现。

You can use this code in your DOCUMENT_ROOT/.htaccess file: 您可以在DOCUMENT_ROOT/.htaccess文件中使用以下代码:

RewriteEngine On
RewriteBase /

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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