localhost does not redirect to virtual host

Problems with the Windows version of XAMPP, questions, comments, and anything related.

localhost does not redirect to virtual host

Postby freeportgreuel » 11. February 2010 19:55

I have read the FAQ’s and searched the forum, but nothing appears exactly like my problem. If there is a problem/resolution out there, kindly redirect me. Now on to my problem…

I am installing XAMPP 1.7.3 on Windows XP SP3. When I type in http://localhost, I am redirected to http://localhost/xampp. Everything looks fine in http://localhost/xampp.

The result I am trying to get is to enable www.example.com to redirect to localhost. So that when I type in www.example.com/xampp I am directed to the xampp setup page. Or if I type www.example.com/store I am directed to my store website residing in /htdocs.

To do this I edited C:\WINDOWS\system32\drivers\etc\hosts with the following info:
127.0.0.1 localhost
::1 localhost
127.0.0.1 www.example.com
::1 www.example.com
127.0.0.1 mail.example.com
::1 mail.example.com
127.0.0.1 example.com
::1 example.com

However when I type in www.example.com I get:
You have reached this web page by typing "example.com", "example.net", or "example.org" into your web browser.
These domain names are reserved for use in documentation and are not available for registration. See RFC 2606, Section 3.

When I type www.example.com/xampp/ I get:
Not Found
The requested URL /xampp/ was not found on this server.
_______________________________________
Apache/2.2.3 (CentOS) Server at http://www.example.com Port 80


I read in several forums I need to edit my C:\xampp\apache\conf\extra\httpd-vhosts.conf. The following is what I entered in this file:
NameVirtualHost *:80

<VirtualHost *:80>
##ServerAdmin postmaster@dummy-host2.localhost
ServerName localhost
DocumentRoot "C:\xampp\htdocs"
##ServerAlias http://www.dummy-host2.localhost
##ErrorLog "logs/dummy-host2.localhost-error.log"
##CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>

<VirtualHost *:80>
##ServerAdmin postmaster@dummy-host2.localhost
ServerName www.example.com
DocumentRoot "C:\xampp\htdocs\store"
##ServerAlias http://www.dummy-host2.localhost
##ErrorLog "logs/dummy-host2.localhost-error.log"
##CustomLog "logs/dummy-host2.localhost-access.log" combined
<Directory "C:\xampp\htdocs\store">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


After making the changes to the httpd-vhosts.conf file, the results were the same as if I had not edited the file.

I have rebooted Windows multiple times and restarted Apache after each file change, but alas the results are all the same as described above. What am I missing to get www.example.com to work?
freeportgreuel
 
Posts: 5
Joined: 31. January 2010 03:53

Re: localhost does not redirect to virtual host

Postby LooseCannon » 12. February 2010 11:00

I've only time for a very quick look freeportgreuel.

All I spot straight away are the '::1' entries in the hosts file. This is tcp/ip6 or something related? I recall seeing this cause issues in Vista, tho I see you're running XP. Are they needed? If not, comment them out?

/me rushes bask to work...
User avatar
LooseCannon
 
Posts: 162
Joined: 18. September 2007 12:07
Location: Hampshire, UK

Re: localhost does not redirect to virtual host

Postby freeportgreuel » 12. February 2010 16:30

An update on my situation... I have another computer at Home that is running XP SP3 and I loaded up XAMPP on that machine. Everything works fine; both localhost and www.example.com. I did the exact same install except I only modified the hosts file and not the httpd-vhosts.conf. So this morning I fired up WinMerge on the Work XP machine to compare the two xampp directories. The only difference was in the hosts, httpd-vhosts.conf, and httpd.conf files. I made these files the same as the working xampp on the Home XP machine, rebooted, cmd > ipconfig /dnsflush, and then started Apache and MySql from the XAMPP Control Panel. Arghh. Same result. I saw a thread where this might be a FireFox 3.6 issue, so I fired up IE6 and had the same result.

Here is the updated hosts file:
127.0.0.1 localhost
127.0.0.1 www.example.com


Thoughts?
freeportgreuel
 
Posts: 5
Joined: 31. January 2010 03:53

Re: localhost does not redirect to virtual host

Postby LooseCannon » 15. February 2010 13:00

No idea about the browser affect.

I believe it's "ipconfig /flushdns", but would guess that's your typo in the post, not what you typed at the cmd prompt, 'cos one gets the help info when one enters "../dnsflush".

Try a different ServerName?

Apache IS running on the PC? In your latest post you mention starting it, but I just asking if it did start and remained running. If so, I guess one doesn't need to check the config with, errr, I can't remember. "apache -t"?
User avatar
LooseCannon
 
Posts: 162
Joined: 18. September 2007 12:07
Location: Hampshire, UK

Re: localhost does not redirect to virtual host

Postby freeportgreuel » 15. February 2010 16:01

Loose Cannon,
I appreciate the assistance. I think I've isolated the cause to either the corporate firewall or the firewall installed on my Work PC. To test this theory, I installed VirtualBox (http://www.virtualbox.org), WinXP with all the patches and then XAMPP. In this controlled environment I was able to use localhost or www.example.com with none of the issues discussed above. I don't have access to the firewall installed on the PC, so I am unable to confirm if this is the issue or not.

Anyway, now when I want to play with XAMPP at work I will use this virtual environment to create my local test sandbox. This might be an option for others who experience "weird" issues that have no logical explanation.
freeportgreuel
 
Posts: 5
Joined: 31. January 2010 03:53


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 151 guests