Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I currently have all my websites as directories under /var/www. I would like to set up a virtual host http://foo/ that points to the /var/www/foo/foo directory (and still keep the default localhost behavior).

I added the following file, foo, to /etc/apache2/sites-available/:

<VirtualHost *:80>
    ServerName foo
    DocumentRoot /var/www/foo/foo

    # Other directives here
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/foo/foo>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

I then ran the following commands:

sudo a2ensite foo
sudo /etc/init.d/apache2 reload

But when I go to http://foo/ it still returns an ISP search page.

share|improve this question

3 Answers 3

up vote 11 down vote accepted

You need to edit your /etc/hosts file so that http://foo resolves to 127.0.0.1.

Edit the file /etc/hosts (with sudo/root) and add the following line:

127.0.0.1 foo
share|improve this answer

For those using apache. You will need to

Ensure you have .htaccess in root path of the site you are hosting. Example /var/www
Update the /etc/apache2/sites-available/default

From

<Directory /var/www/>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride None
 Order allow,deny
 allow from all
</Directory>

To

<Directory /var/www/>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
</Directory>

Hope this helps someone

share|improve this answer
    
Shouldn't the 2 directory blocks be different? –  gion_13 Mar 6 at 7:57

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.