htaccess的重定向 - 自动添加WWW。如果没有子域存在 [英] .htaccess redirect - automatically add www. if no subdomain exists
本文介绍了htaccess的重定向 - 自动添加WWW。如果没有子域存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我查阅了其他职位,但不能找到一个完全满足我的需求。
I have reviewed other posts but cannot find one that fully addresses my needs.
我需要的任何WWW。自动添加到我的域名只有一个子已不存在。我想子域绕过此重定向。
I need any www. added automatically to my domain ONLY IF a subdomain is not already there. I do want subdomains to bypass this redirect.
我怎样才能做到这一点?
How can I do this?
推荐答案
要自动添加 WWW
你的域名时,没有一个子域,这增加在您的文档根目录下的htaccess文件:
To automatically add a www
to your domain name when there isn't a subdomain, add this to the htaccess file in your document root:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
这篇关于htaccess的重定向 - 自动添加WWW。如果没有子域存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文