[英]Redirect rule for only home page from http to https
我们可以只为首页制作https吗?
example.com 或 http://example.com 或 www.example.com 或 http://www.example.com
其余所有页面均应以http开头。
我已经尝试过了,但是没有用
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} "^/$"
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule ^(.*) http://%{HTTP_HOST}%{REQUEST_URI}
没有真正测试过,但应该做魔术
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/?$ https://%{HTTP_HOST}/ [R,L]
RewriteCond %{SERVER_PORT} ^443$
RewriteRule !^/?$ http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
您还可以在根目录级别的.htaccess中像这样重定向:
DirectoryIndex index.html
Redirect 301 /index.html https://www.website.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.