Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm using XAMPP on Windows and I'm trying to set up a virtual site on 8080 port. I'm using the following conf:

Listen 80
Listen 8080

NameVirtualHost *:80
NameVirtualHost *:8080

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

<VirtualHost *:8080>
    DocumentRoot "C:/xampp/htdocs/site2/"
    ServerName localhost
</VirtualHost>

In site2 I have files...

site2/img/profile_pic.png and site2/icons/led/map.png

I can open the first one in my browser using the http://localhost:8080/img/profile_pic.png but the second one returns 404 when I try to open it (http://localhost:8080/icons/led/map.png)

The funny thing is that when I enter http://localhost:8080/icons it list the folder c:\xampp\apache\icons

Whats happening here?

share|improve this question
    
Do you have anything in the Apache logs? –  Bill Weiss Feb 2 '11 at 22:31

3 Answers 3

up vote 0 down vote accepted

Search the httpd.conf config file, you will probably find a default directive defining a link to c:\xampp\apache\icons

http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias

share|improve this answer
    
I managed to figure it out on my own... but thanks man! :) –  rusbi Feb 2 '11 at 21:53

Virtual hosting expects that you use the domain name in your request. For example:

http://localhost:8080/whatever

is just going to try and serve up the default site.

You need to set servername to the domain name of the site. For example "domain1.com" and "domain2.com".

You should set your hosts file (for testing) to:

127.0.0.1 domain1.com
127.0.0.1 domain2.com

and then go to each site in your browser like so:

http://domain1.com/test/file.bmp

http://domain2.com:8080/test/otherfile.bmp

share|improve this answer
    
Also the point of virtual domains is to have more than one address on a single port. So is there any reason you are specifying port 8080 for the second domain as opposed to having both on 80? –  Antonius Bloch Feb 2 '11 at 20:19
    
Are you sure about that? Because it works for /img/profile_pic.png but not for /icons/led/map.png... Why is it working for the first case then? –  rusbi Feb 2 '11 at 20:21
    
I want to test my site from the root directory... I cant relocate xampp because I need phpAdmin. Also, I want it to be accessible from the internet... it all done on my computer... –  rusbi Feb 2 '11 at 20:23
    
I'm think your config is partially working because you each site ends up being the default for it's respective port number. –  Antonius Bloch Feb 2 '11 at 20:25
    

Anyways... I found the source of my problem... The configuration was correct, the problem was with an alias defined somewhere in the default configuration used to display icons for directory listings... The alias was for /icons/ the same directory I use... so, mistery solved :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.