How do I get a domain alias to go to a different fold on my webite?

If you have a domain alias setup for your primary domain and want it to point to a specific folder in your directory structure, you will need to write redirect code.  For example, the domain www.FirstSite.com is the primary domain and it has an alias named www.SecondSite.com but want it to point to a specific folder named /sitefiles.  Below is examples of redirect code that will do this.  This script will need to be put into your application.cfm file.  Below that is a redirect example using Java.


ColdFusion Redirect Script Example:
<cfscript>
switch (cgi.server_name)

// This is a server variable. Do not change this line.
{

// Change this section for your second domain alias.
case "www.SecondSite.com": case "SecondSite.com":
aliasRedirect = "sitefiles/index.htm";
break;

// This section is for the default site, usually your primary domain.
default:
aliasRedirect = "";
}//end switch
</cfscript>

<!--- The following line will redirect the browser to the directory
mentioned above. --->
<cfif len(aliasRedirect)>
<cflocation url="#aliasRedirect#">
</cfif>

Java Redirect Script Example:
<script language="JavaScript">
<!--
/"alert(location.href.toLowerCase());"/
if (-1 !=
location.href.toLowerCase().indexOf('MySecondSite.com'))
location.href='http://www.MyMainSite.com/MySecondSiteDirectory/';
else if (-1 !=
location.href.toLowerCase().indexOf('MyThirdSite.com'))
location.href='http://www.MyMainSite.com/MyThirdSiteDirectory/';
else if (-1 !=
location.href.toLowerCase().indexOf('MyFourSite.com'))
location.href='http://www.MyMainSite.com/MyFourSiteDirectory/';

 

//-->
</script>


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 2194