Automatic subdomains

Ive searched forum and Google but without any luck.

Im trying to make 3rd level subdomain to be working by creating a directgory directory.


home: /htdocs/ - /htdocs/www - /htdocs/www - /htdocs/abc - /htdocs/xyz

Im thinking about VirtualDocumentRoot or mod_rewrite

like: to

RewriteRule !^/www - [C]
RewriteCond %{HTTP_HOST} ^(www.)?
RewriteRule ^/(.*) /www/$1 [L]

all to dir /xyz

#RewriteCond %{HTTP_HOST} !^www.* [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)
RewriteCond /somewhere/ -d
RewriteRule ^(.*) /%1/$1 [L]

I had no luck with
System Settings -> Server Templates -> Default Template -> Virtual Server Creatio

Any idea how to do this within Virtualmin automaticly (and avoiding mod_rewrite e.g.?) Thanks you


I don’t fully follow what your asking but I think all you need to do is create a sub server. The structure is slightly different though:

/home/server/public_html - (and www if you have that configured in the template)
/home/server/domains/ -
/home/server/domains/ -

Hope this is helpful,

thats not exactly what Im looking for. Ok, here is example with full URL:

/home/server/domains/ - (and
/home/server/domains/ -
/home/server/domains/ -
/home/server/domains/ -
/home/server/domains/ -

aka any directory at /home/server/domains/ will create 3rd domain for

Hi, okay I see what you want. I’m not sure if that is possible though. Perhaps Andrew, Joe or Jamie will be able to provide that insight. Do you have a professional license for Virtualmin? If so I would open a support ticket.

I’ll let you know if I discover anything that may be helpful.


Sorry, there unfortunately isn’t a built-in way to do that.

The best way I can think of would be to create a catch-all sub-domain, and setup a .htaccess file in it that redirects something like path.maindomain.tld to maindomain.tld/path/.

That would give you something similar I believe… would that perhaps do what you’re after?