Alias virtual servers (domain aliases) are perfect if you have two or more domains and need them to mirror each other (serve the same web contents, provide the same mail addresses etc.). To create an alias, first start with the master virtual server that the others will mirror, and make sure it works as you need it to. Then, to create an alias do the following:
Make sure you have enabled the web virtual server, otherwise you will not be able to serve websites from your domain. You can enable the web virtual server from Virtualmin by doing the following:
-
Select the virtual server from the drop-down in the left-hand navigation (your main virtual server should be already selected when you first login to Virtualmin).
Click Edit Virtual Server in the left-hand navigation.
Click Enabled features
Select Web virtual server enabled? and click Save Virtual Server
-
Select an existing domain from the drop-down in the left-hand navigation that you want to create an alias for (your main domain should be selected when you first login to Virtualmin).
From the left-hand navigation, click Create Virtual Server.
From the top of the Create Virtual Sub-Server page, click Alias of …
For Domain name field, enter the name for your alias (omit any http://... or www. parts) and a brief description in the Description field.
Click Enabled features. Only some features will appear in the list here, such as those that the parent virtual server has enabled.
Select Setup website for domain? and Enable PowerDNS domain?
Finally, Click Create Server.
This alias will show the destination domain’s content without changing the URL. If you want to redirect to the destination domain, you need to add something to the destination domain’s root .htaccess file, eg 301 redirect anything that isn’t your.domain.name:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(your\.domain\.name)$
RewriteRule (.*) http://%1/$1 [R=301,L]
(the ”%1” will add your.domain.name from the RewriteCond)