Changing default apache index page
Tim
ignored_mailbox at yahoo.com.au
Wed Jul 18 11:36:11 UTC 2012
On Tue, 2012-07-17 at 20:44 -0400, Alex wrote:
> I have an fc17 box with a few virtual hosts, all of which have
> index.php as their index page. For some reason it continues to go to
> the default fedora welcome page, despite there being an index.php in
> the document root.
>
> Even with the only reference to DirectoryIndex in httpd.conf being
> "DirectoryIndex index.php", and nothing else, it continues to go to
> the welcome page. I've tried making index.php first, followed by
> index.html, and it doesn't change.
>
> If I wrap the DirectoryIndex around "<Directory />" tags, it works as expected.
Without seeing your configuration files, we can't really tell what's
going on. There are settings that can override settings, depending on
the sequence of entry. If you put your modifications into the
configuration at the wrong spot, they mightn't do what you want.
> What is the proper way to ensure my index.php page is loaded for all
> virtual hosts, and the default /var/www/html page?
Check the manual for Apache. If you installed it, and it's configured
that way, you can just append manual to the local web address, to read
the manual through your web browser. e.g. http://localhost/manual And
look at the sample configuration supply, it usually has several
commented examples in it.
You can put options in it based on the file system and/or the URI path.
If you're making everything the same, then doing the file path way may
be a one-setting-for-all (i.e. everything above /var/www to be treated
the same), else you'd do it in the configurations for each virtual host.
In my *old* Apache configuration, I have a line like this in the main
configuration file, outside of any <Directory> or <Location> clauses:
DirectoryIndex index.html index.html.var
It, first looks for an index.html file, then tries an index.html.var
file. If you want multiple options, list your first choice first.
The main configuration file has a commented main server section, has
that option set, in the example configuration file after, not inside,
some <Directory> clauses.
And, inside my customised <VirtualHost _default_:80> clauses, I have
overriding options, like this.
DirectoryIndex homepage default index.html
That'll first look for a homepage (dot something) file, then try a
default (dot anything-or-other) file, then index.html files. Allowing
for the most obvious homepage.html for the document root, the logical
default.html (or default.shtml, et cetera)) pages for sub-sections, then
the usual index.html file (that usually isn't actually an "index").
If you just want one default document for any directory path, then just
put one file name in there.
My configuration file has a separate NameVirtual host section, it begins
like this:
NameVirtualHost *:80
<Directory /var/www/virtuals/>
AllowOverride all
Options Indexes FollowSymLinks MultiViews Includes
</Directory>
<VirtualHost *:80>
ServerName www.lan.example.com
ServerAlias example lan.example.com
UseCanonicalName On
ServerAdmin tim at lan.example.com
DocumentRoot /var/www/virtuals/examplecom
DirectoryIndex homepage.html start.html default.html index.html
ErrorDocument 401 /401.shtml
ErrorDocument 403 /403.shtml
ErrorDocument 404 /404.shtml
ErrorLog logs/example-error_log
CustomLog logs/example-access_log combined
XBitHack Full
</VirtualHost>
It's customised for my purposes, but it should give you a template to
experiment with. You don't need the half of it, though.
NB: I keep my virtual hosts outside of /var/www/html, so that it's a
lot harder for someone to cross between different virtual hosts, by
accident of malicious design.
--
[tim at localhost ~]$ uname -r
2.6.27.25-78.2.56.fc9.i686
Don't send private replies to my address, the mailbox is ignored. I
read messages from the public lists.
More information about the users
mailing list