簡體   English   中英

將所有請求重定向到非www https

[英]Redirect all requests to non-www https

我已經在SO上尋找我的問題的解決方案,但沒有一個答案對我有用。

這是我想要實現的:

Redirect all

http://example.com -> https://example.com
http://www.example.com -> https://example.com
https://www.example.com -> https://example.com

基本上,我希望訪問域的任何形式都可以重定向到非WWW httpshttps://example.com

您可以在.htaccess使用:

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

暫無
暫無

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

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