我的网站已在https://example.com
上托管但问题是,当我尝试使用https://www.example.com访问它时,它仍然可以访问。但我不希望用户使用www而不是用户访问该网站我想将其重定向到https://example.com。我该如何实现呢?
这是当前的.htaccess
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
答案 0 :(得分:0)
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]