Conditionally 301 or redirect based on domain it came from

ISAPI_Rewrite is a powerful URL manipulation engine based on regular expressions
User avatar
Posts: 4
Joined: 20 Mar 2013, 00:04

Conditionally 301 or redirect based on domain it came from

20 Mar 2013, 00:08

Please HELP!

We have a dropdown list that allows our customer to switch from the page they are on to one of our other language sites with the same URL.

Example you are on http//www.spanish.es/About/AboutUs.asp and select English from the dropdown list which would redirect you to
http//www.english.com/About/AboutUs.asp

The problem I am having is trying to 301 redirect old links (for example on our English site) to new URL on (the English site) and only redirect old links from the other domains (Spanish, Chinese, German) to the new URL on the English site.

How do I distinguish within the English site which domain the link is coming from?

When I do the following it does not work:

RewriteCond Host: www\.spanish\.es
RewriteRule /About/AboutUs\.html http\://www\.english\.com/About/AboutUs.asp [I,R]
RewriteRule /faqlibraryan/.* http\://www\.english\.com/Support/FAQLibrary.asp [I,R]


RewriteCond Host: www\.chinese\.cn
RewriteRule /About/AboutUs\.html http\://www\.english\.com/About/AboutUs.asp [I,R]
RewriteRule /faqlibraryan/.* http\://www\.english\.com/Support/FAQLibrary.asp [I,R]


RewriteCond Host: www\.german\.de
RewriteRule /About/AboutUs\.html http\://www\.english\.com/About/AboutUs.asp [I,R]
RewriteRule /faqlibraryan/.* http\://www\.english\.com/Support/FAQLibrary.asp [I,R]


RewriteCond Host: www\.english\.com
RewriteRule /About/AboutUs\.html /About/AboutUs.asp [I,RP]
RewriteRule /faqlibraryan/.* /Support/FAQLibrary.asp [I,RP]

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Conditionally 301 or redirect based on domain it came fr

20 Mar 2013, 06:28

Hello,

"The problem I am having is trying to 301 redirect old links (for example on our English site) to new URL on (the English site) and only redirect old links from the other domains (Spanish, Chinese, German) to the new URL on the English site."
- You should specify the proper RewriteCond Host: directive before EACH rule depending on the domain:

RewriteCond Host: www\.spanish\.es
RewriteRule /About/AboutUs\.html http\://www\.english\.com/About/AboutUs.asp [I,R]
RewriteCond Host: www\.spanish\.es
RewriteRule /faqlibraryan/.* http\://www\.english\.com/Support/FAQLibrary.asp [I,R]


RewriteCond Host: www\.chinese\.cn
RewriteRule /About/AboutUs\.html http\://www\.english\.com/About/AboutUs.asp [I,R]
RewriteCond Host: www\.chinese\.cn
RewriteRule /faqlibraryan/.* http\://www\.english\.com/Support/FAQLibrary.asp [I,R]


RewriteCond Host: www\.german\.de
RewriteRule /About/AboutUs\.html http\://www\.english\.com/About/AboutUs.asp [I,R]
RewriteCond Host: www\.german\.de
RewriteRule /faqlibraryan/.* http\://www\.english\.com/Support/FAQLibrary.asp [I,R]


RewriteCond Host: www\.english\.com
RewriteRule /About/AboutUs\.html /About/AboutUs.asp [I,RP]
RewriteCond Host: www\.english\.com
RewriteRule /faqlibraryan/.* /Support/FAQLibrary.asp [I,RP]

User avatar
Posts: 4
Joined: 20 Mar 2013, 00:04

Re: Conditionally 301 or redirect based on domain it came fr

20 Mar 2013, 12:58

Thank you Anton. I really appreciate your quick response!

Return to ISAPI_Rewrite 2.x

Who is online

Users browsing this forum: No registered users and 7 guests