2012-03-23 16 views
5

Ich muss bestimmte URLs auf einer Sub-Domain zu völlig anderen URLs auf einer anderen Sub-Domain umleiten. Zum Beispiel:Wie kann ich bestimmte Subdomain-URLs mit .htaccess umleiten?

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

Needs 301 zu:

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

Ich habe versucht, ein einfaches Redirect 301 in .htaccess Einrichtung, aber es scheint nicht zu funktionieren. Zum Beispiel:

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

wahrscheinlich irgendwo sonst in der Apache-Konfiguration sein. Welches Betriebssystem hast du? –

Antwort

2

Hier ist, was ich tun endete:

# 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

try this:

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

es auf meiner Seite funktioniert

0

, wenn Sie so etwas wie dies wollen:

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

zu

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

aber http://foo.example.com/mypage haben ohne Umleitung

Es ist möglich, reagieren ??

Beacause, dass:

# 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] 

nicht arbeiten muss