Page 1 of 1

Problem with localhost when virtual hosts are working fine

PostPosted: 20. September 2008 19:06
by profsrini
Hi I configured two virtual hosts in my XAMPP for windows environment. This is what I did:

1) I edited hosts file and added the following.

127.0.0.1 localhost
127.0.0.1 www.maria.com
127.0.0.1 www.mary.com

::1 localhost


2) I edited httpd-vhosts.conf file and added the following:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.maria.com
DocumentRoot "C:/xampp/htdocs/maria"
DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml
</VirtualHost>

<VirtualHost *:80>
ServerName www.mary.com
DocumentRoot "C:/xampp/htdocs/mary"
DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml
</VirtualHost>

3) This is my problem:

when I type http://www.mary.com/index.html or http://www.mariah.com/index.html, I see the contents of index.html in browser.

a) If I type http://localhost, I get the error message as follows:

Object not found, Error 404.

I also noticed that the URL changes to http://localhost/xampp.

Before I added virtual hosts, when I type http://localhost, I used to see my index.html displayed in browser.

Did I do something wrong when I configured virtual hosts?

b) Virtual hosts works ok, but I do not understand why I have to type full URL http://www.mary.com/index.html instead of http://www.mary.com.

Did I do something wrong with the set up?

I appreciate your help. I am also adding the part of httpd.conf file which you may be interested to see:

------------ Part of httpd.conf ---------------------
ServerAdmin admin@localhost

ServerName localhost:80

DocumentRoot "C:/xampp/htdocs"

<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>

<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<IfModule dir_module>
DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml
</IfModule>
------------------------------------------------------------------------------------

I sincerely appreciate your help.

Thank You.

Srini
[/code]

PostPosted: 21. September 2008 16:48
by w4vy
remove the index.php file from your htdocs folder, that file you dont need and is what is sending you to localhost/xampp

regards, w4vy

PostPosted: 21. September 2008 17:13
by glitzi85
a) You have to define localhost also in VirtualHosts, DocumentRoot is ignored when you set up VirtualHosts:

Code: Select all
<VirtualHost *:80>
   ServerName localhost
   DocumentRoot "C:/xampp/htdocs"
</VirtualHost>


You can remove the Directory-Index Directive from the VirtualHosts if it is the same as in the httpd.conf.

b) What do you see in error.log / access.log when accessing http://www.mary.com or http://www.maria.com ?

glitzi