简体   繁体   English

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

[英]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.

相关问题 将https://example.com重定向到https://www.example.com - Redirect https://example.com to https://www.example.com 将https://www.example.com重定向到https://example.com - Redirect https://www.example.com to https://example.com htaccess重定向https:// www。 (https://www.example.com)到非www(https://example.com) - htaccess redirect https://www. (https://www.example.com) to non www (https://example.com) htaccess将http://example.com重写为http://www.example.com,但将https://www.example.com重写为https://example.com - htaccess rewrite http://example.com to http://www.example.com but https://www.example.com to https://example.com http://example.com、http://www.example.com和https://example.com到https://www.example.com - http://example.com, http://www.example.com and https://example.com to https://www.example.com 重定向到https://www.example.com - Redirect to https://www.example.com 将https://example.com/重定向到https://www.example.com/而不更改httpd.conf - Redirect https://example.com/ to https://www.example.com/ without changing httpd.conf how to redirect https://www.example.com to https://example.com with .htaccess? - how to redirect https://www.example.com to https://example.com with .htaccess? 如何将https://www.example.com重定向到https://example.com - How to redirect https://www.example.com to https://example.com 如何将 https://www.example.com/aaa 重定向到 https://example.com/aaa/ - how to redirect https://www.example.com/aaa to https://example.com/aaa/
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM