'Laragon auto Vartual host file gets reset on refresh

hi I have many sites that I want to test on local, so when I edit the files on auto virtual host files under Apache->sites-enabled->file name, after reloading laragon, the file resets to its original default contents, ex-

Original
<VirtualHost *:80> 
DocumentRoot "C:/laragon/www/cast.see.tech/public"
ServerName cast.see.tech.test
ServerAlias *.cast.see.tech.test
<Directory "C:/laragon/www/cast.see.tech/public">
    AllowOverride All
    Require all granted
</Directory>
edited
<VirtualHost 192.168.1.101:80> 
DocumentRoot "C:/laragon/www/cast.see.tech/public"
ServerName cast.see.tech.test
ServerAlias *.cast.see.tech.test
<Directory "C:/laragon/www/cast.see.tech/public">
    AllowOverride All
    Order Deny,Allow
    Allow from all
    Require all granted
</Directory>

I cannot save any rules, any code, it comes back to its default original content once I restart laragon server. I am using windows 11, but the same problem I face on windows 10 also. I tried uninstalling and installing back, but still no luck. Currently i am using latest version of laragon 5.0.0 210523, I also tried downgrading the version but still the same problem. Is it a windows issue or do I need to do something else. Please help me with this issue.



Solution 1:[1]

Laragon uses a template to auto-generate the virtual hosts.

On windows, the file is located at C:\laragon\usr\tpl\VirtualHost.tpl, assuming you installed it in C:\laragon.

Just edit this file and make the changes you want.

Keep in mind that all your sites will now use the same configurations.

One change I personally make is to remove the *. from ServerAlias, as I use subdomain format for my sites. Before I remove it, subdomain.example.com would always redirect to example.com.

Solution 2:[2]

Each project has each own Virtual Host file located in:

For Apache: {LARAGON_ROOT}\etc\apache2\sites-enabled\auto.{project}.test.conf

For Nginx: {LARAGON_ROOT}\etc\nginx\sites-enabled\auto.{project}.test.conf

Content of a .conf file is auto generated. If you have a specific project which has modified content, just remove the auto. prefix, Laragon will keep the content of the .conf file intact.

Virtual Host content is configurable, you can change it by modifying the template in:

{LARAGON_ROOT}\usr\tpl\VirtualHost.tpl

https://laragon.org/docs/pretty-urls.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman
Solution 2 jay suthar