I'm learning how to create virtual hosts on apache2. I have Ubuntu 16.04 operating system. I also have WSL (Ubuntu 16.04) in Windows 10.
Now, here's what I observed when I made a virtual host on Ubuntu OS:
I created following VH:
#Did work <VirtualHost *:80> ServerName xyzvk.com ServerAlias www.xyzvk.com DocumentRoot /var/www/xyzvk.com </VirtualHost> #Didn't work <VirtualHost *:80> ServerName xyzvk.com ServerAlias www.xyzvk.com DocumentRoot /var/www/yolo </VirtualHost>
and added both name and alias in /etc/hosts
When I accessed the url in browser. I worked fine.
Now when I changed the DocumentRoot and restarted server, and tried again, it simply didn't work. It sent me to default root, i.e., /var/www/html
I did the same procedures, except the hosts file, which I edited in Windows hosts file as changing in Ubuntu's hosts file didn't work (maybe because it's Windows OS).
The things worked both way this time, irrespective of the directory name.
So my question is: Is it just a convention to name folder same as domain name (if yes, what can be issues that it didn't work in Ubuntu OS) OR it's mandatory?