Create a folder in htdocs folder named test.local and create index.php file in it.
To create a virtual host in Apache just follow simple steps :-
- Go to C:\xampp\apache\conf\extra\httpd-vhosts
- Paste the below code
Here test.local is your virtual host, you can change as per your choice.
NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin email@example.com DocumentRoot "C:/xampp/htdocs/test.local/" ServerName test.local ErrorLog "logs/test.local-error.log" CustomLog "logs/test.local-access.log" common <Directory "C:/xampp/htdocs/test.local/"> Options Indexes FollowSymLinks Includes ExecCGI Require all granted </Directory> </VirtualHost>
3. Go to C:\Windows\System32\drivers\etc\hosts
4. You can see the below code already
# localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost
Below this code just paste your code where you have to mention your virtual host:-
5. Restart Xampp
6. Type in your browser:-
test.localThese designations allow the administrator to use one server to host multiple domains or sites off of a single interface or IP by using a matching mechanism.