.htaccess - 将所有内容重定向到非www

时间:2016-03-12 21:29:45

标签: .htaccess redirect

如何将所有网页重定向到非www https?

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

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

由于

1 个答案:

答案 0 :(得分:2)

使用:

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]