繁体   English   中英

将www.example.com和https://www.example.com重定向到https://example.com

[英]Redirect www.example.com and https://www.example.com into https://example.com

我有一个名为https://example.com的URL

我想将请求从www.example.com和https://www.example.com重定向到.htaccess文件中的https://example.com

各位能帮帮我吗?

谢谢!

在您的.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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM