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 working on image hosting imgur clone. I created a subdomain for my images i.localhost Added to the hosts file -> i.localhost Added to httpd-vhosts.conf ->

<VirtualHost *:80>
   DocumentRoot "/Users/BillGates/Sites/images/"
   ServerName i.localhost

My site is running on my local machine at localhost. Visitor can see the image at url like localhost/NE2bd, I did this url with Mod_Rewrite so it's all like imgur.com

Since I store all my images in /Users/BillGates/Sites/images/ I can't see an image at i.localhost/NE2bd.jpeg !!!! But the image is in the images folder!!

I am getting Not Found

The requested URL /NE2bd.jpeg was not found on this server. My httpd-vhosts.conf

# Virtual Hosts
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
# You may use the command line option '-S' to verify your virtual host
# configuration.

# Use name-based virtual hosting.
NameVirtualHost *:80

# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/usr/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/usr/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common

<VirtualHost *:80>
   DocumentRoot "/Users/BillGates/Sites/images/"
   ServerName i.localhost

And of course some important lines in httpd.conf

DocumentRoot "/Users/BillGates/Sites"

share|improve this question
Post your configuration file? –  quanta Sep 20 '11 at 12:33
I updated topic start –  Sharky Sep 20 '11 at 13:27
Can you post the mod_rewrite directives you use to rewrite the URL? –  xofer Sep 20 '11 at 14:22
Insert a ErrorLog directive into i.localhost virtual host and try again to see what does it say. –  quanta Sep 20 '11 at 14:27

2 Answers 2

up vote 0 down vote accepted

Looks like you are using Apache 2 on OSX, and that the file that you are editing is /etc/apache2/extra/httpd-vhosts.conf. Some of the code that you have copied and pasted appears to be missing <VirtualHost *:80>

Perhaps the configuration that you have added to is not being read into the apache configuration. By default this file is not read in. You could try editing the main /etc/apache2/httpd.conf to include this file.

Try uncommenting the line:

Include /private/etc/apache2/extra/httpd-vhosts.conf.

And of course remember to start and stop apache for it to take effect.

share|improve this answer
The OPs formatting was incorrect –  Iain Sep 20 '11 at 14:09
nickgrim, yes I forgot to uncomment the line including httpd-vhosts –  Sharky Sep 20 '11 at 15:32
Now, When I go to localhost I get the index (list od images) of Sites/images –  Sharky Sep 20 '11 at 15:48
Assuming that you mean that when you go to i.localhost you see a list of all the images, and that you don't want to show the list of files by default, perhaps you could try adding an index.html or similar default file to the folder Sites/images –  digitalsean Oct 3 '11 at 9:09

Your configuration looks wrong. I am used to declare a vhost like

<VirtualHost *:80>
ServerAdmin webmaster@host.foo.com
DocumentRoot /www/docs/host.foo.com
ServerName host.foo.com

in a file which gets included in your httpd.conf.

I am not sure if your configuration is even used by Apache, because your "localhost"-vhost doesn't exist in your configuration.

Try to add the domains "foo.bar" and "i.foo.bar" in your /etc/hosts and point them to your IP. Then write a VirtualHost directive for each of them with different DocumentRoot's.

After that, try to reach the files located in the directories with your (sub-)domain and post errors (and configs).

share|improve this answer

Your Answer


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.