我需要写一个 htaccess 只强制主页非 ssl
因此,如果您要访问 https://www. 123.com 或 https://123.com它将重定向/强制它转到 http://www. 123.com 或 http://123.com .
我只想在主页上进行此更改。
最佳答案
我没有要测试的 https 框,但我认为这些规则应该可以满足您的要求:
<IfModule mod_rewrite.c>
RewriteEngine On
# Only rewrite if using HTTPS and that we're on the index page, then redirect to http
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/index.[a-z]+$ [NC]
RewriteRule .+ http://%{SERVER_NAME}%{REQUEST_URI} [R,QSA]
</IfModule>
关于.htaccess - 仅强制主页为非 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14966816/