Stop Alias virtual server from redirecting to the main domain

Dear community, after creating a new Alias Virtual Server, by default it redirects to the main domain. How do I stop it from redirecting?

Am I configuring it in a wrong way?

 

Please note that I turned the Apache Website Enabled OFF because I guess I don’t need a new home directory to serve an existing website with an alias.

image

 

I can confirm that there is no domain name listed in the Apache server configuration for the main domain. Please advise.

Operating system: MacOS
OS version: Bug Sur

But an alias domain will, by design, show the website of the main domain.

Why use an alias if you do not wish to show the main domain?

It does not. It redirects to the main domain.

Could you create a virtual server as alias with default values? Don’t change anything - let’s then see if you get a redirect or an actual alias.

I have the same thing setup on main domain cloudcart.indiax.com with alias www.adventurezone.in for a multi-site hosting setup, which is what you are after too, I presume @antonphp. The system I use for this is:
Operating system Debian Linux 10
Webmin version 1.962 Usermin version 1.812
Virtualmin version 6.14 Authentic theme version 19.62
Kernel and CPU Linux 4.19.0-14-cloud-amd64 on x86_64
Processor information Intel® Xeon® CPU E5-2686 v4 @ 2.30GHz, 2 cores

@antonphp,

Did you by chance have “Apache SSL Website” enabled on the parent domain?

If so, it likely has a “Website Redirect” enabled which is set at the VirtualHost level. When this is triggered because the Alias is added as as ServerAlias of the parent domain, it’ll do a redirect by default.

To change this behavior, visit “Server Configuration > Website Redirects” of the parent domain.

Delete the redirect rule which should look something like:

URL path:
/

Type:
Redirect to URL

Destination:
https://parent-domain.com/$1

If you want to have http to https redirection after this is complete, you can create a “.htaccess” file at the root of the website and add something like:

RewriteRule on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This method will respect the “hostname” used in the request and will not redirect to the parent domain like the rule created through Website Redirects which uses a different redirect method.

Best Regards,
Peter Knowles | TPN Solutions

1 Like

Re-creating the Alias virtual server with “Apache website enabled” did the job.

So, this is a head up for the development team - you should adjust the help text that appears in the popup box when the "Apache website enabled?" option is clicked.

This piece of text is incorrect:

… a new website home directory will be created

No new directories in Home are created.

This piece of text is incorrect as well:

… a new VirtualHost configuration section will be added

No new VirtualHost configuration section is added either. Instead, just a new ServerAlias is added.

If I understand it correctly, the confusion arises because the same help text is used in both cases:

  • when creating a top-level virtual server
  • when creating an alias virtual server

If this is the case, then what is needed is to display a different help message depending on what type of server is being created.

Finally, the option name itself, Setup website for domain?, should be changed to something more self-explanatory for the Alias case.

Makes sense?

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