Using base href with different domains

We're having some problems with our base href. Here's the setup:

We have several sub domains which all resolve to the same site:

In our environments.xml we have:

<environment name="web1" urls="">
  <Setting name="SesBaseURL" value="" /

<environment name="web2" urls="">
  <Setting name="SesBaseURL" value="" /

<environment name="web3" urls="">
  <Setting name="SesBaseURL" value="" /


In our page headers we have:

<base href="#getSetting('sesBaseURL')#">

The problem is that the sesBaseURL setting gets set to whatever URL
was used to last reinit the framework-- not the current URL being used
to access the site.

Is there a better way to accomplish this or is ColdBox just not meant
to be used in an application which can be accessed by different URLs
at the same time?



The environment-interceptor is used for different server environment
settings, e.g. dev,test,live.

Use the request decorator (or create an interceptor) to read
(cgi.server_name) and set SESBaseURLS


here's another approach if you'd like

OK, that seems fair enough. To clarify, only ONE environment at a
time can be used?

I am familiar with how to create an interceptor so that approach seems
pretty straight-forward.
I will dig through the docs for some info on the request decorator.

To be honest though, my actual setup is (not surprisingly) a bit more
complicated than my original example. Each of our environments
actually looks more like this right now:

<environment name="web1" urls="">
  <Setting name="Path" value="" />
  <Setting name="SecurePath" value="https://" />
  <Setting name="SesBaseURL" value="${Path}/master/index.cfm" />
  <Setting name="SecureSesBaseURL" value="${SecurePath}/master/
index.cfm" />
  <Setting name="FullLayoutPath" value="${Path}/master/layouts" />
  <Setting name="Star12FullPath" value="${Path}/STAR12Members" />
  <Setting name="Star12SecureFullPath" value="${Path}/STAR12Members" />
  <Setting name="Star12ImageFullPath" value="${Path}/STAR12Members/
Images" />
  <Setting name="Star12SessionCheck" value="${Path}/STAR12Members/
MemberServices" />
  <Setting name="JoinStar12Now" value="${Path}/STAR12Members/Checkout/
MemberCheckout.cfm" />
  <Setting name="SesBaseURL" value="${Path}/master/index.cfm" />
  <Setting name="SecureSesBaseURL" value="${SecurePath}/master/
index.cfm" />

As you can see, there are actually quite a few paths we have put into
settings (mostly because we expect them to change soon and only want
to have to change them in one place.)

Would I need to set ALL of these in an interceptor or request
decorator? My problem with that is many of these links are also
legitimately different between the environments. I kind of have a two-
fold problem here. I have path differences between servers/domains
that you have told me should be handled by an interceptor/request
decorator and I also have path differences between my environments
which still seem as though I should be using the environment
interceptor to handle.

Also, another item is where I should be setting these paths like my
SESBaseURL. Am I correct that setSetting() will be modifying the
setting for the entire application? It sounds like these need to be
set on a per request level. Should I be finding a way to calculate
all the paths based on environment AND domain and cram all these
settings into the requestContext on every page hit? Perhaps when I
read up on the request decorator things will clear up a bit for me.


Thanks for the link. I'm still trying to digest it a bit. I think part
of my problem is I have never taken the time to fully understand what
routes.cfm is and how it affects me.


You are right: setSetting is used for entire's a
ColdBox config set it once (on framework init), use it

If your vars can be different on each request, you should use the
request decorator or interceptor.
Sure, you can create a setting which hold all different server
settings, but you still need request-functionality to get the right
settings (e.g. using a struct key).