2012-03-23 150 views
5

我需要将子域上的特定网址重定向到完全不同的不同子网域上的网址。例如:我如何301使用.htaccess重定向特定的子域URL?

http://foo.example.com/this-is-my-page 

需要301到:

http://bar.example.com/this-is-really-my-page 

我试图建立在.htaccess简单Redirect 301但它似乎并没有工作。例如:

Redirect 301 http://foo.example.com/this-is-my-page http://bar.example.com/this-is-really-my-page 
+0

可能需要在其他地方在Apache的配置。你在什么操作系统上? – 2012-03-23 19:10:36

回答

2

这里是我落得这样做:

# first re-write all foo.example.com requests to bar.example.com 
RewriteCond %{HTTP_HOST} ^foo\.example\.com [NC] 
RewriteRule (.*) http://bar.example.com/$1 [L,R=301] 

# now re-write each individual URL 
RewriteRule ^this-is-mypage /this-is-really-my-page [NC,L,R=301] 
3

试试这个:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC] 
RewriteRule ^(.*) http://newsub.domain.com/ [L,R] 

,如果你想这样的事情它工作在我身边

0

http://foo.example.com/this-is-my-page 

http://bar.example.com/this-is-really-my-page 

http://foo.example.com/mypage有没有重定向

这是可能的回应?

东阳是:

# first re-write all foo.example.com requests to bar.example.com 
RewriteCond %{HTTP_HOST} ^foo\.example\.com [NC] 
RewriteRule (.*) http://bar.example.com/$1 [L,R=301] 

# now re-write each individual URL 
RewriteRule ^this-is-mypage /this-is-really-my-page [NC,L,R=301] 

不会工作