2012-03-27 136 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

相关问题