Apache: adding aliases messes up rewrite rules

There is a bug in how the apache configuration is created. I have the admin & webmail redirects configured. As soon as I add an alias domain to the virtual server, I get a configuration like so:

RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.maindomain.tld
RewriteRule ^(.*) https://mybusiness.tld/webmail/ [R]
RewriteCond %{HTTP_HOST} =admin.maindomain.tld
RewriteCond %{HTTP_HOST} =webmail.aliasdomain.tld
RewriteCond %{HTTP_HOST} =admin.aliasdomain.tld
RewriteRule ^(.*) https://mybusiness.tld:10000/ [R]

Which is broken in the sense that the alias webmail should be further up, also there should be [OR] at the end of the RewriteCond if there are several. So the correct way I guess would be like so:

RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.maindomain.tld [OR]
RewriteCond %{HTTP_HOST} =webmail.aliasdomain.tld
RewriteRule ^(.*) https://mybusiness.tld/webmail/ [R]
RewriteCond %{HTTP_HOST} =admin.maindomain.tld [OR]
RewriteCond %{HTTP_HOST} =admin.aliasdomain.tld
RewriteRule ^(.*) https://mybusiness.tld:10000/ [R]
Status: 
Closed (fixed)

Comments

I guess this only happens when you have alias domains.

What incorrect behavior do you see with the redirects as Virtualmin creates them currently?

Exactly, this only happens when adding alias domains. Basically, if you look at the conditions i pasted above, the admin.maindomain.tld and webmail.aliasdomain.tld would not work because they get superseeded by the last condition. Also, the webmail.aliasdomain.tld does not belong there as it should redirect to the webmail, not virtualmin.

Perhaps a simple fix is to not add the webmail and admin redirects at all for alias domains, as it seems unlikely that they would be used.

Good point. I can live with that.

Ok, I will go that route then.

Automatically closed -- issue fixed for 2 weeks with no activity.