2012-03-23 111 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] 

不會工作