The subdomain URL is not working; it taking to the main web folder instead

SYSTEM INFORMATION
OS type and version AlmaLinux 9.5
Usermin version 2.102
Virtualmin version 7.30.3
Theme version 21.20.7
Apache version 2.4.62
Package updates 39 package updates are available, of which 18 are security updates

Hello,

I created a subdomain (demo) in Virtualmin, and while the URL is working, the website is loading from the main folder instead of the intended folder.

There are many variations of this problem. We can’t guess which one you have, but it’s always a misconfiguration in Virtualmin. It’s configuring the wrong IP or a mix of IPs and the way Apache decides which site to serve doesn’t match what you think it ought to do.

Since you’re using Cloudflare, that’s probably the source of the trouble. Are you using the tunnel feature? Or are you proxying to the public IP of your server? (Search the forum, the tunneling problem was just discussed.)

It can also be caused by a problem with IPv6 configuration.

In Virtualmin, we have top level virtual servers and sub servers.

A top level virtual server can be:
domain.tld
sub.domain.tld

A sub server can be:
domain.tld
sub.domain.tld

As Joe explained (yet again) recently, top level virtual servers and sub servers are about ownership. A user X is the owner of a top level virtual server for doman abc.tld. Now if you wish the same user X to also be the owner of def.tld, then you should create a sub server in Virtualmin.

However if you are okay with user X being owner of abc.tld and user Y being owner of def.tld then you should create only top level virtual servers.

The creation of top level virtual servers is the norm in Virtualmin and sub servers are intended to be used only in specific cases related to ownership. Also, a top level virtual server can host doman abc.tld and / or subdomain sub.abc.tld.

In this context @vineethachari, tell us what you mean by subdomain, main folder and intended folder.

In Virtualmin, for a top level virtual server for domain abc.tld, the main folder (or directory) will always be /home/abc/public_html

It looks like they created regular virtual servers for everything, based on the folder layout in /home. I don’t think that’s the confusion they have.