Forum Moderators: mack

Message Too Old, No Replies

301 ColdFusion Redirects for Pointed Domains

         

spellcheck

7:25 pm on Oct 15, 2007 (gmt 0)

10+ Year Member



I have a client that has pointed 5 domains to the same IP, creating the same exact content at 5 different URLs. Normally, I would just point the DNS of 4 of those sites to an alternate IP, then do a global 301 redirect to the main site. However, thousands of these pages at the 5 different sites are already indexed in Google. I would like to be able to maintain these rankings, but doing page-by-page 301 redirects is out of the question. Is there a way to automatically redirect all of the pages at the 4 sites to the exact corresponding page (same file name) on the main site? For example. www.widgets1.com/widget/ and www.widgets2.com/widget would automatically redirect to www.widgets.com/widget.

Any help would be greatly appreciated.

coopster

10:29 pm on Oct 15, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, spellcheck.

Yes, it is possible. Are you running an Apache HTTP server? RedirectMatch would be an easy approach. Here is a thread in the Apache forum here at WebmasterWorld that discusses a similar topic, with explanations and solutions:

[webmasterworld.com...]

LifeinAsia

10:43 pm on Oct 15, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If you're using IIS instead of Apache, it's not as elegant, but you could put a redirect in the application.cfm file. If any of the pages are dynamic, you'll have to make sure you pass all the variables as well.

You'll need the following CGI variables:
- SERVER_NAME
- HTTP_SCRIPT_URL
- QUERY_STRING

Let me know if this points you in the right direction, or if you need more of a nudge.

[edited by: LifeinAsia at 10:44 pm (utc) on Oct. 15, 2007]

spellcheck

11:38 am on Oct 16, 2007 (gmt 0)

10+ Year Member



LifeInAsia, I am using IIS and need more of a nudge. Your help is much appreciated.

LifeinAsia

3:17 pm on Oct 16, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Put this in your application.cfm file:
<cfif FindNoCase(CGI.SERVER_NAME,"widgets.com") EQ 0>
<cfset TargetLocation="http://www.widgets.com/#HTTP_SCRIPT_URL#">
<cfif CGI.QUERY_STRING NEQ "">
<cfset TargetLocation=TargetLocation&"?#CGI.QUERY_STRING#">
</cfif>
<cfheader statuscode="301" statustext="Moved permanently">
<cfheader name="Location" value="#TargetLocation#">
</cfif>

I haven't tested it extensively, so it may need some modifications.

LifeinAsia

6:25 pm on Oct 16, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Sorry, that should have been
<cfif FindNoCase("widgets.com",CGI.SERVER_NAME) EQ 0>