Forum Moderators: open
tutorials.domain.com would redirect to
domain.com/get/subdomaindata.cfm?subdomain=tutorials
or
fubar.domain.com would redirect to
domain.com/get/subdomaindata.cfm?subdomain=fubar
etc.. etc.. If not possible with coldfusion, how would I go about accomplishing this (changing httpd or OS is not an option)?
Reading quite a bit; great community here.
Just to clarify, I'd need to include something similar to this in my index.cfm, right? (this is untested)
<cfif #CGI.Server_Name# EQ "tutorials.domain.com">
<cfinclude template="/subdomains/tutorials.cfm">
<cfelseif #CGI.Server_Name# EQ "support.domain.com">
<cfinclude template="/subdomains/support.cfm">
<cfelse>
<regular web-site HTML here for index.cfm>
</cfif>
Thanks for the suggestion! My site is still on my local development server, but I obviously plan on testing some different methods on the production server very soon.
(sorry 'bout the double post)
<!--- length of the root domain, with the leading dot --->
<cfset domainLength = Len(".domain.com")>
<!--- list of all your usable subdomains --->
<cfset subList = "tutorials,support">
<!--- parse server_name to find subdomain --->
<cfset subDomain = Left(CGI.SERVER_NAME, Len(CGI.SERVER_NAME) - domainLength)>
<!--- see if it matches one in your list --->
<cfif ListContains(subList, subDomain)>
<!--- if matches, load that template --->
<cfinclude template="/subdomains/#subDomain#.cfm">
<!--- if no match, handle error gracefully --->
<cfelse>
<!--- Error Handler --->
</cfif>
<cfinclude template="/subdomains/#subDomain(CGI.SERVER_NAME)#.cfm">
That would be cleaner, and more modular for future code reuse.
[edited by: Bluesplinter at 9:00 pm (utc) on Sep. 23, 2006]