我有一个名为https://example.com
的URL我想将请求从www.example.com和https://www.example.com重定向到.htaccess文件中的https://example.com。
请大家帮帮我吗?
谢谢!
答案 0 :(得分:0)
在.htaccess文件顶部检查此规则
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect all www requests to https non www
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule (.*) https://example.com/$1 [R=301,L]
# Redirect all other http requests (ex. http://example.com) to https non www
RewriteCond %{HTTPS} off
RewriteRule (.*) https://example.com/$1 [R=301,L]
</IfModule>