Subdomain based routing to respective install folders

Operating system: Ubuntu
OS version: 20.04
Type: LEMP

I have installed wordpress and roundcube inside public_html folder and so structure is


I created a subdomain domain in BIND entry

and I want that I can point this sub domain to below path


I can do that in nginx on a normal server by editing the nginx file inside sites-available and edit the root line as

root /var/www/html/roundcube;

How do I configure root path of respective subdomains in virtualmin ?

Virtualmin → Server Configuration → Website Options and then put the name of the directory (roundcube or whatever) in ‘Website documents sub-directory’

but that is like changing root path for main domain

on a normal server running nginx, I can create multiple files inside sites-available

and I can route request of

root /var/www/html/roundcube;

and I can create another file in sites-available with

root /var/www/html/wordpress

Now you see basis subdomain request, I can send the request to respective application

Right now in virtualmin it is like

Virtualmin is a GUI for you and your clients to do things that can be done on normal servers.

If you and your clients are happy to edit config files manually (and are sharp enough to remember values, formats and can avoid typos 100% of the time) then you can do everything manually that Virtualmin can do for you via the GUI.

Having said that, I understood from your initial message that you already have a domain working normally with WordPress installed in its own directory, Roundcube installed in its own directory and wish to create sub-domains which will point to these. Based on this I showed you a screenshot of how you could use the Virtualmin GUI to configure roundcube.domain.tld to map to the roundcube directory.

If it as not your intent to point the subdomain to the directory then I do apologize for misunderstanding your question.

I guess you are talking about below option. Note that this is the root path for the root domain

So if I have wordpress folder in
and roundcube in

when I open
www.domain.tld it should directly open wordpress

and when I open
roundcube.domain.tld it should directly open roundcube

how would that be done ?

I have done this on a server by myself but want to understand how I can do on virtualmin

I have activated the subdomain option in
Create Virtual Server
but I don’t know how to change the root document path of this subdomain virtual server. And I think that if done in Virtualmin would do what I achieved on a standalone server

But why are you making this so difficult for yourself?
Either just install RoundCube directly on the subserver, or use Virtualmins documentation on changing webmail globally.
The article is old, but it still works perfectly.

1 Like

Well, I have the solution you want. I start by recreating your setup at

Also in demo1, I point the document root to public_html/wordpress so that www.domain.tld (or renders the /wordpress directory. I do this via Virtualmin → Server Configuration → Website Options

And then I create a new virtual server (in your case, roundcube.domain.tld) and use Virtualmin → Server Configuration → Edit Proxy Website thus:

And there you have it:

  1. Visit (or www.domain.tld) to show the website in the wordpress directory
  2. Visit (or roundcube.domain.tld) to show the website in the roundcube directory

@toreskev is right - it would be easy to point webmail.domain.tld to roundcube instead of the default Usermin.

You installed it wrong.

Go back and uninstall Wordpress. Then go to reinstall it and pay attention. By default it will install it in a Wordpress directory. Right next to that is an option to install it at top level, which will put it directly into the public_html folder. That will make it to where when you go to your domain it goes straight to the Wordpress site without the “wordpress” in the address.

I know I can do that. But then if you have

you cannot install them in the public_html

on a standalone server without virtualmin you can install them in their respective folders like


and just configure their sites-available files in which you can set directives

Also I know what you are trying to telling me. And I know that. I don’t want to do it that way. it is not the correct way to be honest if you have set up servers from scratch by yourself with virtualmin

No kidding. :roll_eyes:

You run your Wordpress at top level because that’s your main page on the web. You run Roundcube to Roundcube. You don’t want to have people accessing webmail by simply visiting the domain name. Same applies to other things. Forum can go to a forum folder so the address ends with /forum.

The point is, whatever your main prescience is on the internet, be it a Wordpress blog or a Xenforo Forum, you install it at top level.

Everything else goes to it’s own subfolder appropriately. It’s been done that way since day one of the internet.

I just wanted one directory to be php 5.6 the rest is fine using php 7.4

I think you replied to the wrong thread.

sorry to say on a build from scratch server it is not like that

you install in subfolders and you manage it using respective file in sites-available of nginx

then after configuring sites-available files of each, when you do

domain.tld or www.domain.tld it goes to wordpress

roundcube.domain.tld would go to roundcube

because with respective sites-available file you can change the root directive value pointing to respective subfolers

somehow I think no one in this forum before virtualmin ever did this on a raw server. I can show a real working demo if you all don’t know this approach

You are trying to reinvent the wheel when there is no need to.

To do it your way in Virtualmin just create a subdomain named for each item you want. It’s instant and automatic. Then install the given software at top level.

Going by your example, you have domain.tld. Install wordpress at top level. Then create a subdomain called roundcube.domain.tld. Install roundcube on that subserver at top level.

But the only thing you’re doing is putting the name before the domain instead of after. It’s ridiculous really to go through all of that for what amounts to no difference at all, but it is very simple to do in Virtualmin and it is all automatic no matter which way you want to do it.


If I create a subdomain roundcube.domain.tld

and install roundcube at top level, is this roundcube managing

email as xyz@domain.tld or ?

You configure that any way you want. That’s why there’s an “edit email alias” menu in each domain and subdomain you create. You can add, subtract, or forward any email from any domain to the other.

Again, it’s all right there in Virtualmin. All you have to do is look.

@Gomez_Adams your approach of sub-server approach worked

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.