Can I have multiple sites sharing the same codebase?

I have multiple sites using Coldfusion 11 and each site uses a MySQL database. Since each of my sites each use a copy of the same codebase I am wondering if there is a way to configure things so that I can have multiple websites share the same codebase. For example,,, and would all use the same codebase but use their own database and the URL is preserved when viewing the site.

Is there a way to configure this?

Thank you
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexandre SimõesManager / Technology SpecialistCommented:
Where are you deploying your website?

The best option is probably to deploy it separately by domain.
What you describe is not a simple configuration/infrastructure problem, the application itself must need to be developed with that kind of usage in mind.
WestCoast_BCAuthor Commented:
Right now my sites are sitting on a shared server.
WestCoast_BCAuthor Commented:
I was looking at this post: how to run multiple sites on same codebase in ColdFusion base on domain or subdomain

and see that they suggest the following:
       <CFSET Application.Environment = "Dev">
       <CFSET Application.Environment = "Prod">

Open in new window

Can I have multiple domains and subdomains all point to the same IP address and still preserve the URL that is displayed when someone is viewing the site?
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Alexandre SimõesManager / Technology SpecialistCommented:
But which is the application server?

Apache? NginX?...
What is the current configuration? Multiple applications per website?
Does you website support multiple tenants?
Alexandre SimõesManager / Technology SpecialistCommented:
The problem is that you don't want to share the same DB.
Because of that, your application must have a way to know which DB to pick based on the logged in user.

Does you app implement this logic?
Dave BaldwinFixer of ProblemsCommented:
If your sites are already running, you can spend a lot of non-productive time making this work.  Because of the support requirements, you may spend more time making the "common code base" work than actually supporting the sites.

I have worked on one site that was set up to be viewed as a dozen different domains.  But every single page was written to support that and it used a single database.  I currently work on a set of four sites that have an 'almost' common code base except that each one has different CSS and javascript files that are customized to that site.  Although much of the PHP code is identical, it would be difficult to make them all work off the same code on one of the sites.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
@Alex... I agree with your perspectives here.

Because of that, your application must have a way to know which DB to pick based on the logged in user.
I have a ASP.NET application where using the same database was simply not an option (databases are in a hosted environment and some of our clients need to replicate the database to their remote sites as well - construction in the middle of nowhere and need offline access to system - so we cannot replicate every other client's data along with that).

In our case, a username actually has a DOMAIN part (domain\username) were the domain is used to determine the database which we use (even to authenticate that user). We have a separate globally accessible configuration database/file which stores additional domain configuration information, such as database names, and a few custom domain settings.

The only requirement for this to work is that any places in the code where we need to do any database communication, the connection information should be parameterized so that the front end can inform which database to use. When a user logs on, it can be easily established which database they must use and this can be kept in a configuration variable of sorts (either in session or other mechanism).

In ColdFusion, this setup can be implemented using the CF Administrator and data sources. In the ColdFusion Administrator, you configure your data sources to communicate with ColdFusion. After you add a data source to the Administrator, you access it by name in any CFML tag that establishes database connections; for example, in the <cfquery datasource="#current_datasource#"> tag. During a query, the data source tells ColdFusion which database to connect to and what parameters to use for the connection. That would achieve the dynamism required here. (My CF syntax might be incorrect)... but the concept would perhaps work,
Can I have multiple domains and subdomains all point to the same IP address and still preserve the URL that is displayed when someone is viewing the site?

Yes, have all domains and subdomains point to the same websites.   Then in your application.cfc file you can check for which website is in the URL using cgi.server_name.   Using a cfswitch statement, you can then assign variables for data source and layout file and website ID or whatever you need to distinguish your different websites even though they are all pointing to exactly the same folder.
WestCoast_BCAuthor Commented:
Thank you everyone for all of your advice.  I will give it a try tonight.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.