0

Right now my default site-enabled looks like this:

ServerName www.my.site.com
DocumentRoot "/opt/site/web"
DirectoryIndex index.php
<Directory "/opt/site/web">
>.Allow from all
>.Satisfy any 
</Directory>
>.

<VirtualHost _default_:80>
  ServerName my.site.com
  DocumentRoot "/opt/site/web"
  DirectoryIndex index.php
<Directory "/opt/site/web">
>.Allow from all
>.Satisfy any 
</Directory>

I want to make it so it serves the site located at /opt/site/web no matter what hostname is supplied. I tried changing the first line to ServerName * but that didn't work... what am I missing?

3 Answers 3

0

See: http://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost

Remove the NameVirtualHost and ServerName directives then the _default_:80 virtual host should serve all requests.

0

Name based virtual hosts are intended to do the opposite of what you want, so you should not be using them and NameVirtualHost should be commented out or not used.

Your configuration should include directives such as the ones below.

<Directory "/opt/site/web">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

DocumentRoot "/opt/site/web"

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

On Centos, default install of Apache will do exactly what you want and you would only need to change the default directory for the html to /opt/site/web

0

I agree with the others in that you should get rid of the VirtualHost stanza.

But you can also use ServerName * as a catch all. This will then match any hostnames not previously listed in your configuration file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .