I tested the option of just changing the DocumentRoot in the httpd.conf file as suggested by fastsol and figured it to work right away. It is absolutely an option, because it is so simple.
Regarding creating a VirtualHost, or even several Virtualhosts, it looks more elegant in the way that one doesn't need to include subdirectories in the URL when watching pages locally in the browser. Unfortunately the procedure to make the VirtualHosts work is not so simple. I tested your code thoroughly, Ch0cu3r, but it didn't work! The link to Apache.org delivered by trq didn't bring me much further to the goal. I don't like the style in Apache.org in general. Often it only states how things should be done, and not WHY. I need explanations in order to understand the logic behind the procedure. At least the explanations at Apache.org are very sparse. I find that if one doesn't understand the structure beforehand, one won't learn anything from looking into the Apache.org documentation. So I went on Googling for other explanations. I found the following pages to be helpful, delivering much better explanations:
In general different pages deliver different procedures on how to create VirtualHosts. It seems somewhat shaky in the sense that if you don't do it in the exact right way, it won't work, and it is difficult to find out what is wrong. For example one should be aware of opening the different files as administrator by rightclicking on Notepad in the Start menu. Secondly the procedure to make VirtualHosts work seems to have been changed in recent versions of Apache. That's at least what I conclude after watching several webpages delivering procedures, which don't work anymore. Anyway, after having used several hours of this subject I finally made it work. Here is how I did:
I have two sites named site1 and site2 located at D:\site1 and D:\site2. I decided to name the VirtualHosts site1.local and site2.local as suggested by one of the pages above. Then I made changes to three different files. Two of them located in the Xampp directory (I have Xampp installed) and the third is a Windows system file:
Make sure to have Windows Explorer set to show all files (also system files), or you won't see anything. Also after having opened Notepad as Administrator by rightclicking on it in the Start menu, one also needs to look for all files *.*, not just text files as the default *.txt. Again if you don't, you can't see the files. Now to the changes:
In the httpd.conf file, I made sure that the comment-sign # in front of the below Include line was removed. I think it is already removed in the newer versions of Apache, but apparently wasn't in earlier versions:
In the hosts file in the Windows system, I added two lines at the end of the file:
The httpd-vhosts.conf file need the most changes. At the bottom you should place the VirtualHosts commands, in which the DocumentRoot and ServerName for each VirtualHost is listed. Notice that it is a good idea also to make a VirtualHost to the localhost. If you don't, you won't be able to use localhost, and maybe more severe: You won't be able to use your local phpMyAdmin! Higher on your page you need to write a Directory command. If you don't, you won't be able to locally access subdirectories via the browser. Finally you should remove the # sign in front of the NameVirtualHost *:80 command already in the file.
Require all granted
# The line below is originally commented out. The #-sign should be removed to make it take action:
Finally when you have made the changes in the three files and having saved the files, it is important that you close and open the Apache server, before you can see the changes having taken action. You can close and open the Apache server in the Xampp Control Panel by hitting a button on the line with the Apache server. And then start it again by hitting it again. Now hopefully things should work for you. You can test it by writing the following URL in a browser:
assuming you have an index.html file in the root of your site (else add the filename to the URL: http://site1.local/somefile.php
Questions: I am not sure why it is necessary and even if it is necessary to uncomment the line NameVirtualHost *:80 in the httpd-vhosts.conf file. If someone know, I would like to hear it. Secondly I am not sure if the "Require all granted" line in the Directory command is the right one to use. Some other websites deliver other commands, but it can have to do with old versions of Apache. I am not sure. I guess it has security questions also. I will appreciate any comments on that too.
At least my Virtual Hosts work now