簡體   English   中英

.htaccess-從www https重定向到非www https

[英].htaccess - redirect from www https to non www https

我有.htaccess:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1 [R=302,NE,L]

當我從(例如)重定向時,它正常工作:從http://重定向到正確的https://從http:// www重定向到正確的https://但當我有https:// www時 我沒有重定向和“非信任連接”。

我應該在htaccess文件中進行哪些更改?

只需在第二條規則上也重定向到https,例如

RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=302,NE,L]

無關,但是您無需捕獲路徑,只需使用REQUEST_URI

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM