If I understand the root of what you're proposing,
it would be to use a local faux variable, CGI_SERVERNAME,
and assign the true CGI.SERVER_NAME to that, and finally
assigning the value of CGI_SERVERNAME to _host.

The "_host" value would be the value in the local hosts file.

One part that is confusing is this:

<cfif CGI_SERVERNAME is "localhost">
        <!---// put host to simulate here //--->
        <cfset CGI_SERVERNAME = "my.simulated.host.domain.com" />
</cfif>

If I'm trying to differentiate between several different domains
in my local hosts file, how is that being done with the code above?
It seems that there would have to be an entry with <cfif></cfif>
for each local hosts domain involved to set the variable, rather than
depending on what's in the url for the value.

I could see this working like that:

<cfif cgi.server_name is 'localhost' and cgi.script_name contains
'siteName'>
        <cfset cgi_servername = 'www.siteNameLocal.com'>
</cfif>

However, it doesn't avoid the manual entry of the above code for
every local domain name, does it?  Or what am I failing to understand?

Rick


-----Original Message-----
From: Dain Anderson [mailto:[email protected]] 
Sent: Thursday, February 24, 2011 9:09 AM
To: cf-talk
Subject: Re: I think I'm confused...


One technique for this is to alias the CGI variables you use:

<cfset CGI_SERVERNAME =  CGI.SERVER_NAME />

And when you're developing locally, you can set that value as something else
to mimic the host you want to simulate.

<cfif CGI_SERVERNAME is "localhost">
    <!---// put host to simulate here //--->
    <cfset CGI_SERVERNAME = "my.simulated.host.domain.com" />
</cfif>

Then, you would fetch host-specific settings, etc, based on the aliased
value.

<cfset _host = CGI_SERVERNAME />

<cfquery datasource="#ds#" name="getAccountID">
select iaccountid from #schema#sa_accounthosts
where vchhost = <cfqueryparam cfsqltype="cf_sql_varchar" value="#_host#" />
</cfquery>

...then fetch settings for the account.


This type of setup can be used to have multiple host aliases for a single
account. A good example of this would be host1.domain.com and
host2.domain.com, but wanting them to share account data.

<cfquery datasource="#ds#" name="getDefaultHost">
select vchhost from #schema#sa_accounthosts
where bDefault = <cfqueryparam cfsqltype="cf_sql_char" value="1" />
and iaccountid = <cfqueryparam cfsqltype="cf_sql_varchar"
value="#getAccountID.iAccountID#" />
</cfquery>

<cfif getDefaultHost.RecordCount>
   <cfset _host = getDefaultHost.vchhost />
</cfif>





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342567
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to