Remove Virtual Host from Hosts File
-
Hello,
First I want to say thanks for this awesome tool, really help beginners like me to have a good development environment on Windows machine.
I want to ask how to remove virtual host entry from the Hosts file and httpd-vhosts.conf?
For example, I created a simple native PHP project inside C:\laragon\www\myproject to try Laragon.
Note: the project's name is myproject.Laragon then automatically create virtual host so myproject url became myproject.dev.
The Hosts file then have this line:
127.0.0.1 myproject.dev #laragon magic! C:/laragon/www/myproject/And also there is few lines at C:\laragon\bin\apache\apache-2.4.17\conf\extra\httpd-vhosts.conf.
But when I delete myproject from C:\laragon\www\ that line not removed from my Hosts file and httpd-vhosts.conf.
How to remove those lines from Hosts file and httpd-vhosts.conf?
Is it safe to just delete them both manually?Thank you
-
Yes, it's totally safe
-
So just to be clear, to completely remove a project and it's virtual host, I need to do this steps:
- Delete the project's folder from www (www/myproject)
- Go to httpd-vhosts.conf and remove these lines:
<VirtualHost *:80> #laragon magic!
DocumentRoot "C:/laragon/www/myproject/"
ServerName myproject.dev
</VirtualHost> - Go to drivers/etc/hosts and remove:
127.0.0.1 myproject.dev #laragon magic! C:/laragon/www/myproject/
Am I correct?
-
Yes, you're correct!
You can only do Step 1. Next time, when you put new folder in www, Laragon will clean 2, 3 for you.
-
I see, thanks Leo.
After a few tests, I want to note this for future reference if I forgot, and for anyone else having this same question
So, Laragon will auto remove deleted project's virtual host settings from Hosts and httpd-vhosts.conf when you add a new project to www folder.
For example, you currently have project A, B, and C in www folder.
Then you delete project A and B.
The Hosts file and httpd-vhosts.conf will stay the same as before.
But when you add a new project, lets say X, Laragon will remove virtual host settings for A and B from Hosts and httpd-vhosts.conf, then make a new virtual host for X.So as we can see, Laragon can make virtual host for new project, and auto remove it when its project deleted from www folder.
Awesome!