在一个IP虚拟主机设置上将子域redirect到另一个网站

我很抱歉,如果之前已经问过这个问题,但是我已经在这里看了很多问题,他们都没有回答我的问题。

我有一系列域指向我的服务器。 对于每一个我已经设置它的IPlogging,并正确地在http.conf中configuration一个VirtualHost,如下所示:

# example.com <VirtualHost *:80> DocumentRoot /path/to/example ServerName example.com ServerAlias example.com ServerAlias www.example.com </VirtualHost> # other.com <VirtualHost *:80> DocumentRoot /path/to/other ServerName other.com ServerAlias other.com ServerAlias www.other.com </VirtualHost> 

现在我在我的服务器上为test.other.com设置了一个IP,我想将其redirect到一个完全的其他网站:test.blogspot.com(因为它移动了)。

我尝试了以下,但它将所有网站redirect到该网站

 # other.com <VirtualHost *:80> ServerName test.other.com ServerAlias test.other.com Redirect / http://test.blogspot.com/ </VirtualHost> 

我想这是因为“/”? 不太确定。 我试过VirtualHost test.other.com:80但没有工作。 我尝试了一堆东西,没有工作,所以我真的需要你的帮助。

提前致谢。

你可以用htaccess文件来做,只需要创build几个修改即可。 使子域有一个适当的目录:

 <VirtualHost *:80> ServerName test.other.com ServerAlias test.other.com DocumentRoot /path/to/directory </VirtualHost> 

然后用这个内容在那个目录中创build一个.htaccess文件

 Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://newdomain.com/ 

同样可以写在Apache网站的configuration,我只是觉得更容易pipe理htaccess文件。