Virtual Server creation writes code in the wrong .conf

Until some time ago (3 months I guess, in which I did each and every update), when ever I created a new Virtual Server it created a conf file in /etc/apache2/sites-enabled/.conf

which contained among others the following lines:

RewriteCond %{HTTP_HOST} =webmail. RewriteRule ^(.) https://:20000/ [R] RewriteCond %{HTTP_HOST} =admin. RewriteRule ^(.) https://:10000/ [R]

While these rules, especially the second one were not really useful to me, they are no written to a different file.

I defined a template which automatically include a second conf by inserting 'Include /…/…/Someconf.conf' (shared for all Virtual Server) in to each Virtual Server conf.

It always worked, but recently instead of writing the 4 above mentioned lines of code in to the Virtual Server's own conf, it inserts them into the shared conf.

The location where the line are written are directly behind a existing RewriteRule.

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f #existing rule in shared conf RewriteCond %{REQUEST_URI} /icons/(.).(gif|jpg|jpeg|png)$ #existing rule in shared conf RewriteRule ^(.) /icons/generic.png #last line of existing rule in shared conf RewriteCond %{HTTP_HOST} =webmail. RewriteRule ^(.) https://:20000/ [R] RewriteRule ^(.) /icons/generic.png #even more strange, as it does not write the admin. RewriteCond, but copies the last line of the existing rule in the shared conf RewriteRule ^(.*) https://:10000/ [R]

I was able to reproduce this on several Servers.

Status: 
Closed (fixed)

Comments

It could be that the use of an include file is causing this.

Does this problem still happen even if you don't have that include in your template?

I would recommend against this, as Virtualmin may attempt to add lines to that include file, if they are for a directive that is already in the file.

The file I include did not change since june. And it was possible after june to create new Virtual Server without the behaviour explained above.

Ass the included conf is absolutely needed for the Sites to work and has work until recently it would be a shame if t did not work anymore.

I will test if removing the RewriteCond/RewriteRule from my conf fixes the problem.

One alternative would be to just directly include the contents of that file in the Apache config template, rather than using an include line.

Seems to be fixed with some of the last updates