与子域htaccess的文件中删除WWW
我有一个品种,是子域的特定网站的网站。 http://sub.domain.com 的 http://apple.domain.com 等。
I have a variety of sites that are subdomain specific sites. http://sub.domain.com http://apple.domain.com etc.
用户偶尔会抱怨,该网站不能正常工作,然后我发现他们去 http://www.sub.domain.com 或的 http://www.apple.domain.com 并予以满足各种各样的服务器错误页面
users occasionally complain that the site is not working and then i find out they went to http://www.sub.domain.com or http://www.apple.domain.com and are met with a server error page of sorts
有什么样的魔力htaccess的我需要打开 http://www.sub.domain.com - > http://sub.domain.com
what kind of htaccess magic do i need to turn http://www.sub.domain.com -> http://sub.domain.com
感谢
* FWIW我没有通过previous问题搜索请求之前,并没有发现我的答案
*fwiw i did search through previous questions before asking and did not find my answer
如果虚拟主机是真的指向同一个文档根目录的www.sub.domain.com和sub.domain.com,你可以放置一个的.htaccess文件具有以下在doc-根内容:
If the VHost is really pointing to the same docroot for www.sub.domain.com and sub.domain.com, you can place a .htaccess-file with following content in the doc-root:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^sub\.domain\.com$ [NC]
RewriteRule (.*) http://sub.domain.com$1 [R=301,L]
这将重定向所有指向该文档根到sub.domain.com
That will redirect all domains which are pointing to this docroot to sub.domain.com
编辑:
有关在一个单独的.htaccess文件的多个子域:
For multiple Subdomains in one single .htaccess-file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.([^\.]*)\.domain\.com$ [NC]
RewriteRule (.*) http://%1.domain.com$1 [R=301,L]
这是从头顶未经测试。