I have many domains (www.vf1.com, www.vf2.com, www.vf3.com etc) which all point to my main domain (www.vf.com). How do I do a 301 redirect from these other domains to my main domain?
So if someone hits www.vf1.com/news/1234 they should get redirected to www.vf.com/news/1234
I also have domains such as images.vf.com, css.vf.com and js.vf.com that I don't need redirecting
I'm using ColdFusion 8 on IIS (but I don't have access to IIS at the moment)
I tried the below on a URL such as http://www.festivalreviews.co.uk/latest/news/14500 but it gets redirected to http://www.virtualfestivals.com/index.cfm
<cfif cgi.http_host IS 'www.festivalreviews.co.uk'>
<cfset jjURL = 'http://www.virtualfestivals.com' & CGI.PATH_INFO>
<cfheader statuscode="301" statustext="Moved Permanently">
<cfheader name="Location" value="#jjURL#">
</cfif>
Thanks
I agree with Adam, if possible, this would probably be better handled using your web server. Having said that, I have had to do similar things in the past with ColdFusion. When I need to rebuild URLs I typically use different CGI variables than what you tried. See if this works for you.
CGI.SERVER_NAME- Server's hostname, DNS alias, or IP addressCGI.SCRIPT_NAME- Virtual path to the script that is executingCGI.QUERY_STRING- Query information that follows the ? in the URL that referenced this scriptYou can read more about the CGI variables in the documentation here.