Same HTML files but different database connections for subdomains

Hi guys,

I would like to do the following thing, but I can not figure out how to do it:

I am developing an application which has many users. Each user has their own separated MySQL database. I’d like to setup Apache virtual hosts, and every vhost serve HTML files from the same directory, but every user have to connect to their own database.

Serving HTML files for every vhosts from the same directory is easy, not problem, I set the DocumentRoot in every vhosts to the same location.
The problem is somehow redirecting requests of dmxConnect/modules/Connections/myconnection.php which should contain different database location for each users/vhosts.

for eg.:

App HTML files are under

User1 subdomain is

User2 subdomain is

User3 subdomain is

Sounds a little bit complicated, but I hope you can understand what I mean :slight_smile:

I have tried to place a different “myconnection.php” to User1, User2, User3 subdomain folders and write “Alias dmxConnect/modules/Connections/myconnection.php /var/www/user1/myconnection.php”, but it was unsuccessful.


Hi Attila,

Nice project!

Currently the connect files use static values as those are more common.

However you can try using expressions like:


And especially point to environment variables.
I think it was $_ENV

So something like:


Etc for the different user settings.

So enter those instead of static values. And make sure the right variables get set.

You also use $_SESSION from php session variables or $_SERVER

Of course when you save such a db connection the test will fail, but you can still choose to save it.

Let me know if that works.

I will add some more data pickers so you can choose the expressions more easily in the next updates.


Thank you!!! This ENV variable thing working well, you made my day! :beers:

1 Like