Redirect to domain. "www" gets lost.


following scenario:

I have three host names on my local machine:

They all point to the same application.

When I kill my jrun and call the the application with look_new the first time everything is okay. When I use the next hostname “” I get a redirect (302) to look_new.
So all the Links are build with look_new as well…

The problem on the live system is, that the page can be called with “www” and without. It now seems that the first call of the site has been done with just the domain name.
So everyone using “www” gets a redirect.

Is it a bug or a feature ? -Can it be turned of ?

regards Andy

That is because ContentBox and ColdBox rely on the baseUrl, this is configured at the time ColdBox and ContentBox is first run and setups the application.

So in your case, if you browse with out the www, then that is what gets stored in the cached pages for baseUrl, which is the same if done the other way.

The only solution, is to have a different ApplicationName that detects the url change and sets the Application name accordingly.

ColdBox caches the BaseSESURL in a setting so it will be set on the first request. All you need to do is use the Multi-domain SES interceptor here on ForgeBox:

All it does is set the current domain into the event object at the beginning of each request. What way you can have any number of domains used to access your site and links will get built using the domain that the user is on.

arguments.event.setSESBaseURL(“http://” & cgi.http_host & “/index.cfm”);

If you’re using URL rewrites, you’ll want to remove the index.cfm.



ColdBox Platform Evangelist
Ortus Solutions, Corp

ColdBox Platform:

Thanks. The other problem will disappear with the new rewrite. Site will always be accessed with WWW.
For multi domain this is cool!