There is nothing to see in the VirtualHost setup. If there is a redirect, there must be another reason. Tell us about the software you are running. Its alway a good idea to start with an "empty" project (for each VirtualHost). Simply put a single index.html into each DocumentRoot (and nothing else, especially no files called .htaccess - which are hidden in a Linux environment, use "ls -la" in a terminal to see them or try to press "Ctrl. h" in an Explorer showing the DocumentRoot) which also contains only a single line like "I am website1" or "I am website2". And then call the URL for the VirtualHost in a browser (i.e.
http://website1.com and
http://website2.com). If this shows up correctly, you know that the VirtualHosts are configured properly.
A note anyway: your DocumentRoots are "overlapping", the DocumentRoot of website2 is a subfolder of the DocumentRoot of website1. That is never a good idea, as one can reach website2 not only via
http://website2.com, but also via
http://website1.com/site2. You really should use completely different folders for different VirtualHosts, why not d:/xampp/htdocs/site1 for website1.com? To make things worse, d:/xampp/htdocs already is the DocumentRoot of localhost, i.e. the base htdocs folder for the Xampp installation. As Xampp comes with a .htaccess file in the htdocs folder, this .htaccess will influence both of your VirtualHosts! You should create totally new folders for your new VirtualHosts, like d:/xampp/vhosts for example and finally create a subfolder for each DocumentRoot like d:/xampp/vhosts/website1 and d:/xampp/vhosts/website2, or even one steṕ more like d:/xampp/vhosts/website1/htdocs and d:/xampp/vhosts/website2/htdocs or similar. If you do so, you must add a "Require all granted" to the DocumentRoot of the VirtualHosts (see the definition of d:/xampp/htdocs in httpd.conf).
Last not least, you say you are working on Linux, but Linux does not know drive letters like D: - this configuration is NOT a Linux configuration, its a Windows Xampp configuration instead!
but it's simply too complex for someone who has no prior knowledge on the topic and Linux.
What Linux??
Pranav wrote:but the first step is to ask for help.
I dont agree. The first step ALWAYS should be to read documentation. Thats the idea of documentation, if everybody asks instead, we dont need documentation. Only if you have difficulties to understand certain details or if things go wrong and not as expected, then go for help. But what i dont like most, when people overtake some suspicious code lines (or configuration lines) without thinking, without any knowledge, without knowing what it does and without understanding it. Its so easy nowadays with the help of the Internet and Google and all these documentions, i wish i had these when i was a beginner. When i started learning programming, there was nothing like that.