configuring virtual host and localhost redirecting to the xampp folder
Solution 1
I had this same issue. Your first request is redirecting to the htdocs root directory. If you look at index.php in the htdocs directory, you can see very brief code that takes the incoming request and redirects it to the xampp directory.
I fixed it by fiddling with the httpd-vhosts.conf file. In your case, try making the following edits:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "C:\xampp\htdocs\
ServerName localhost
</VirtualHost>
<VirtualHost www.myhost>
DocumentRoot "C:\Users\Me\Dropbox\Project\public"
ServerName www.myhost
ServerAlias www.myhost
<Directory "C:\Users\Me\Dropbox\Project\public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Solution 2
I had a similar issue and found that I had to go to my Apache24 main httpd.conf file and uncomment around line 501 "Include conf/extra/httpd-vhost.conf" I had never used that before and it was still #'ed out. Hope this helped anyone not finding other answers here. My Apache24 can now see my vhost file.
Solution 3
You need to enable name-based virtual hosting.
Near the top of the file in C:\xampp\apache\conf\extra\httpd-vhosts
uncomment #NameVirtualHost *:80
i.e. from:
#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
To:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
(Note the last line now is uncommented).
Worked like a charm for me. :)
Solution 4
try this
[ file : C:\xampp\apache\conf\extra\httpd-vhosts.conf ]
<VirtualHost basic.test:80>
DocumentRoot "C:/xampp/htdocs/basic/public/"
ServerName basic.test
</VirtualHost>
[ file : C:\Windows\System32\drivers\etc\hosts ] (open as admin)
127.0.0.1 basic.test
127.0.0.1 localhost
Related videos on Youtube
woyaru
Updated on July 22, 2022Comments
-
woyaru almost 2 years
I have problem with creating virtual host. I am using Windows 7 x64 Professional. In file
C:\Windows\System32\drivers\etc\hosts
I have only this lines:127.0.0.1 myhost 127.0.0.1 www.myhost
And in file
C:\xampp\apache\conf\extra\httpd-vhosts.conf
I have this:NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/" ServerName localhost ServerAlias www.localhost </VirtualHost> <VirtualHost *:80> DocumentRoot "C:/Users/Me/Dropbox/Project/public" ServerName myhost ServerAlias www.myhost <Directory "C:/Users/Me/Dropbox/Project/public"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
And of course I have restared my Apache server after adding this lines in those files. Unfortunatly typing
myhost
orwww.myhost
in my browser redirect me to themyhost/xampp
.I have already search and I have found on google and also on stackoverflow description how to configure virtual hosts using xampp but how can I recognize I have done everything alright. I know that my problem isn't new but I didn't found working solution for me.
I have also recognized that typing
localhost
in my browser redirect me alstolocalhost/xampp
. I don't know whether these problems are linked in my case.-
Raj over 7 yearsFollow below URL which has working solution Working with localhost and virtualHost
-
-
Don Question over 11 yearsI doubt this was the Problem of the OP, because in his 2nd code-block it's the first (uncommented) line! ;-) But nevertheless welcome to SO! :-)
-
jave.web about 8 yearsFor my current testing XAMPP (1.8.1) the config file
httpd-vhosts.conf
is located inXAMPP_INSTALLATION\apache\conf\extra