1

I am setting up several sites on an ubuntu 14 server with apache2. I copied 000-default.conf and created a site1.conf. Then I changed some settings, reloaded apache2, and now almost everything works. Except that my default document in the DirectoryIndex setting is not being honored. My site1.conf looks similar to this:

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  ServerName site1.com
  DocumentRoot /var/www/site1
  ServerAlias *.site1.com
  DirectoryIndex one.php
</VirtualHost>

But my problem is that visiting http://site1.com/ still shows index.html instead of one.php which I want it to show. Be aware that once I get this working I want to setup site2.com and have it use the default document of two.php.
I'm guessing that DirectoryIndex is a setting that doesn't work inside VirtualHost and instead is a global setting in apache2.conf. I searched for this stuff and can't find a good explanation or way to do it.

4
  • Is it index.html from /var/www/site1/index.html? Or is it from /var/www/index.html Jul 3, 2014 at 19:44
  • Where else, in all of your configuration files, have you set DirectoryIndex? Jul 3, 2014 at 19:47
  • Well the word DirectoryIndex does not appear in my apache2.conf. I didn't have an .htaccess file when I started this, however after I encountered the problem I created one to test this and put in the line: "DirectoryIndex one.php" but it still doesn't server up one.php. I can't think of any other places to look.
    – user229209
    Jul 3, 2014 at 23:11
  • It is showing the /var/www/site1/index.html when I ask for site1.com
    – user229209
    Jul 3, 2014 at 23:13

2 Answers 2

0

not sure if you need one.php inside site two or viseversa but you could always do:

DirectoryIndex one.php two.php three.php

And once site1.com looks for default file and it sees one.php it will use that as default. and other site2.com would not find one.php as it will show two.php?

But depends upon what is ur full requirement.

1
  • Thanks for the idea. This wil work for me at the moment.
    – user229209
    Jul 5, 2014 at 11:22
6

I'm guessing that DirectoryIndex is a setting that doesn't work inside VirtualHost and instead is a global setting in apache2.conf.

There is no need to guess it's in the documentation

For Apache 2.2 DirectoryIndex is valid inside a VirtualHost context, and the same goes for Apache 2.4 DirectoryIndex.

You must log in to answer this question.

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