2010-11-05 63 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]