2010-11-05 80 views
0

干草,在Plesk中,它使我能够将一个子域添加到域名为x.y.com,问题在于www.x.y.com被视为另一个子域。有没有办法将所有来自www.x.y.com的流量引导至x.y.com?我尝试在php中使用300头来做这件事,但像www.x.y.com/mypage这样的东西没有被重定向。我可以使用.htaccess文件重定向所有这些流量吗?htaccess问题

感谢

+0

Modrewrite /重定向可以工作,但虚拟主机配置是干净多了 – 2010-11-05 12:54:31

回答

0
# you probably want www.example.com to forward to example.com -- shorter URLs are sexier. 
# no-www.org/faq.php?q=class_b 
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{HTTPS} !=on 
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] 
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 
</IfModule> 

来源:http://html5boilerplate.com

0
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^www.x.y.com [NC] 
RewriteRule ^(.*)$ http://x.y.com/$1 [R=301,L]