subdomains

hi, I know I posted this before but I can’t find it, and I can’t remember the setting. When I create a subdomain instead of it creating a new domain alltogether, I would like it to forward to a folder on the parent domain. ie sub.mydomain.com on my server would be /home/mydomain/public_html/sub/ instead of /home/mydomin/sub/

I know this is possible as I have done it before, don’t need mailboxes or new databases or anything for the new domain, I just want it to forward to the other directory

You can go to Services - Configure Website and change the home directory

You can indeed either create a sub-server and set its web site document root, although that might interfere with some of Virtualmin’s functions, since it probably does not expect the document root to be outside the sub-server’s home.

Another way is to not create a sub-server, but add an A entry to the parent server’s BIND DNS Domain, with a name of `sub.mydomain.com" and IP address identical to the parent.

Then you go to Configure Website -> Edit Directives and add this to the config:

RewriteEngine on RewriteCond %{HTTP_HOST} =sub.mydomain.com RewriteRule ^(.*) http://www.mydomain.com/sub/ [R]

Unfortunately, using mod_rewrite is the only way to redirect URLs with a hostname part other than that of the main server, and Virtualmin has no “graphical” editor for mod_rewrite rules (which I can understand - mod_rewrite is the voodoo of Apache :slight_smile: ).