[英]Redirect www.example.com and https://www.example.com into https://example.com
i have a URL called https://example.com 我有一个名为https://example.com的URL
I would like to redirect request from www.example.com and https://www.example.com into https://example.com in .htaccess file. 我想将请求从www.example.com和https://www.example.com重定向到.htaccess文件中的https://example.com 。
Could guys please help me? 各位能帮帮我吗?
Thanks! 谢谢!
Check this rule on the top of your .htaccess file 在您的.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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.