[英]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.