• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

multiple domains pointing to one application

Participant ,
Apr 02, 2008 Apr 02, 2008

Copy link to clipboard

Copied

hi there

if you check these 2 sites out:

http://www.southendlocaljobs.co.uk/

and

http://www.chelmsfordlocaljobs.co.uk/

it looks to me like that is the same application that those 2 different domains points to, but pressumably the application is also passed a 'townid' so it knows what text variances to display.

this isnt my application but we have a need to do something similar.

we are running CF8 on windows sever (2003 i think).

is this something one handles in IIS? or via somesort of rule in application.cfm

does anyone know what is considered best practice with this?

what about duplicate content from google's perspective etc.

thanks very much indeed for any help you can offer.
TOPICS
Advanced techniques

Views

977

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

Does anyone have any comments to make on my above question?

All help would be very gratefully received.

Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

happysailingdude wrote:
>
> thanks very much indeed for any help you can offer.
>

There are many possibilities. But one of the easiest identifier is the
URL. One can inspect the url used to access a web application with the
CGI scope. With this piece of information it is rather trivial to
configure a site to offer up specific content based on this site 'id'.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

To vary the content by the domain name look at each request's cgi variables, such as cgi.server_name or cgi.http_host, and generate your content accordingly.

To setup multiple domains to point to the same website you need have multiple domain names associated with your site's public IP address.

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Expressions_8.html#2679705

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

thanks very much for your replies chaps,

so we have 2 issues here then it seems:

1. how does the application know which site the user is visiting (and thus what content to serve)

2. how to configure the webserver / DNS etc.



--part 1--
It seems you're both saying that looking at the CGI vars is the way to go for part 1. I understand from the cfdocs that not all browsers support all of the different cgi vars, does anyone have any first hand experience of this? should i look at cgi.server_name or cgi.http_host?

maybe i need to look at both? that leads me onto the question of performance... does putting <cfif cgi.http_host contains 'abc.com' or cgi.server_name contains 'abc.com' > into application.cfm represent a potential performance issue?

also what if some browser somewhere doesnt pass either cgi.http_host or cgi.server_name - then what?

--part 2--
re DNS etc - forgive me this isn't my strong point, so i'll probably ask my host to assist with this, but if anyone could please give me a simple outline of what i'm seeking to achieve re the DNS / hosting etc that would be great as then i can pass that onto my host


Thanks very much indeed - your help is much appreciated

Nick

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

happysailingdude wrote:
> --part 1--
> It seems you're both saying that looking at the CGI vars is the way to go for
> part 1. I understand from the cfdocs that not all browsers support all of the
> different cgi vars, does anyone have any first hand experience of this? should
> i look at cgi.server_name or cgi.http_host?

Slight misunderstanding here. CGI variables come from the web server
not the web browser. Yes different servers offer somewhat different
sets of CGI variables. Some CGI values are more universal across
servers then others. But you should be well aware of what web server
(i.e. IIS, Apache, whatever) you are using and can adjust your code
accordingly.

> --part 2--
> re DNS etc - forgive me this isn't my strong point, so i'll probably ask my
> host to assist with this, but if anyone could please give me a simple outline
> of what i'm seeking to achieve re the DNS / hosting etc that would be great as
> then i can pass that onto my host

DNS is a simple database of domain names matched to IP addresses. So
how what we are discussing works is that you make multiple entries into
this database, one for each domain name, all pointing to the same IP
address of you application.

I.E.
www.southendlocaljobs.co.uk -> 111.222.111.222
www.chelmsfordlocaljobs.co.uk -> 111.222.111.222

There is a bit more to it then this, but your hosting provider is going
to understand the details and be able to walk you through this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

thanks Ian

sorry about the mix up re CGI vars - thanks for clarifying that.

thanks also for the info re the DNS side of things.

just one quick question relating to "part 1" if i may..

you say "different servers offer somewhat different
sets of CGI variables. Some CGI values are more universal across
servers then others. But you should be well aware of what web server
(i.e. IIS, Apache, whatever) you are using and can adjust your code
accordingly." - we're running IIS - so ought we to base our cfif statements in application.cfm around cgi.server_name or cgi.http_host would you suggest?

oh yes, did you have any comments to make about any performance issues of this putting this logic in application.cfm? (do you think that something like this would be better than interrogating the cgi var on each and every page?

<cfif not isdefined("session.siteid") >
<cfif cgi.HTTP_HOST contains "southendlocaljobs.com" >
<cfset session.siteid = "southend" >
</cfif>
<cfif cgi.HTTP_HOST contains "chelmsfordlocaljobs.com" >
<cfset session.siteid = "chelmsford" >
</cfif>
</cfif>

thanks very much indeed for your help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

sorry my code lost its formatting - here it is again for clarity:

<cfif not isdefined("session.siteid") >
<cfif cgi.HTTP_HOST contains "southendlocaljobs.com" >
<cfset session.siteid = "southend" >
</cfif>
<cfif cgi.HTTP_HOST contains "chelmsfordlocaljobs.com" >
<cfset session.siteid = "chelmsford" >
</cfif>
</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

Grrr! and again - ignore the fullstops

<cfif not isdefined("session.siteid") >
....<cfif cgi.HTTP_HOST contains "southendlocaljobs.com" >
........<cfset session.siteid = "southend" >
....</cfif>
....<cfif cgi.HTTP_HOST contains "chelmsfordlocaljobs.com" >
........<cfset session.siteid = "chelmsford" >
....</cfif>
</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

Rather than using repeating cfif statements, each of which must be evaluated, I'd use cfswitch or cfelseif so that evaluation will end when a match is found.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

happysailingdude wrote:

> you say "different servers offer somewhat different
> sets of CGI variables. Some CGI values are more universal across
> servers then others. But you should be well aware of what web server
> (i.e. IIS, Apache, whatever) you are using and can adjust your code
> accordingly." - we're running IIS - so ought we to base our cfif statements in
> application.cfm around cgi.server_name or cgi.http_host would you suggest?

I do not have direct knowledge if what CGI variables are where with
which servers. Whenever I start developing an application that will use
CGI variables, I just do a quick <cfdump var="#cgi#"> to see what I have
to work with today in the current environment.

>
> <cfif not isdefined("session.siteid") >
> <cfif cgi.HTTP_HOST contains "southendlocaljobs.com" >
> <cfset session.siteid = "southend" >
> </cfif>
> <cfif cgi.HTTP_HOST contains "chelmsfordlocaljobs.com" >
> <cfset session.siteid = "chelmsford" >
> </cfif>
> </cfif>

That is a fine idea. I'm not sure of the performance gain, but I
suspect there is a small one over inspecting the cgi variable every
request. If you are hype concerned about performance though,
theoretically integers are more efficient then strings. If you care to
take it to this level you would set your siteid to simple integers, i.e.
1,2,3,etc.

I've never needed to be concerned with this level of performance. But
it is my understanding <cfif session.siteid is 1> is a tiny bit faster
then <cfif session.siteid is 'southend'>. But of course at the cost of
code clearity. Who is going to remember 1 = soutend six months from now.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

hi Bob, good point thanks, would you go down the session var route or just interrogate the cgi scope on every page?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

quote:

Originally posted by: happysailingdude
hi Bob, good point thanks, would you go down the session var route or just interrogate the cgi scope on every page?


If you plan to require sessions and will use them to store data other than just the site id you could check for the existence of your session variable then only create it as needed. I'd also follow Skinner's suggestion to store interger IDs rather than site names in your sessions to keep your session objects small.

If the session's only purpose is to track the site I would avoid using session and just check the site on every page request since using session creates overhead for your CF server (bear in mind that search engine robots are notorious for creating extraneous sessions on your server).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 04, 2008 Apr 04, 2008

Copy link to clipboard

Copied

LATEST
Thanks very much for your help Bob and Ian

I have summarised my conclusions here (based on the help ive received) for anyone else reading this forum later on:

to achieve the aims outlined at the top of this post:

1. use CGI vars to deduce the domain the visitor has requested
2. different server's O/S will give you access to cgi.http_host or cgi.server_name (or both) - use cfdump #cgi# to see what you've got
3. use cfswitch or cfelseif statements in application.cfm to deduce which site your visitor is after
4. if you're using sessions already then set the siteid as a numeric (rather than string), if you're not using sessions then dont do so just for this as they put an overhear on the server (when googlebot visits) and the cfswitch logic isn't very heavy on processing
5. your host will help you with DNS - ask them to set it up so you have an entry for each domain pointing to the same IP address of your server

that's about the size of it i think (do feel free to correct me / add to this if you wish)

thanks again for your help chaps - is much appreciated

Nick

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation