2012-03-27 139 views
1

我有域名site.com,並有subdomain sub.site.com 一旦你打開sub.site.com你必須看到site.com/sub/沒有URL格式。 如何做到這一點?如何在不重寫URL的情況下重定向頁面?

+0

你運行一個apache? – devsnd 2012-03-27 07:57:21

+0

您認爲您使用的Web服務器可能是相關的? – 2012-03-27 07:57:33

+0

是的。 Apache上的Debian – Alexey 2012-03-27 07:57:52

回答

1

您可以創建虛擬主機或虛擬主機來執行此操作。在那裏你可以很容易地定義一個服務器別名,它透明地重定向到你的目錄。

例如,如果你的Apache配置是這樣的:

<VirtualHost 13.37.13.37> 
DocumentRoot /www/where/ever/your/webroot/is 
ServerName www.example.net 
</VirtualHost> 

現在添加第二個虛擬主機:

<VirtualHost 13.37.13.37> 
DocumentRoot /www/where/the/other/site/is 
ServerName example.net 
ServerAlias othersite.example.net 
</VirtualHost> 

見:http://httpd.apache.org/docs/2.0/vhosts/examples.html

+0

沒有使用根權限的方式嗎?我一個也沒有。 – Alexey 2012-03-27 08:03:43

+0

不需要。然後你必須使用.htaccess和mod_rewrite。但你的網址將失去它的'漂亮'... – devsnd 2012-03-27 08:08:31

相關問題