# Apache always serving index.html



## pcfxer (Apr 14, 2010)

I have moved from nginx to Apache only to run into a wall. I have a domain, http://www.potvindover.ca and a redirect dover.homeunix.net. If I use http://www.potvindover.ca I can only see the index.html file, even if I specified /test.php or what have you. The interesting thing is that Apache serves an index.html file out of thin air, because the index.html in my document directory does not have "It Works!" anywhere...

If I use the redirect I get access to my test.php and my index.html that I have in my directory... Here is my httpd.conf:


```
potvindover# cat /usr/local/etc/apache22/httpd.conf 
ServerRoot "/usr/local"


Listen 80

LoadModule authn_file_module libexec/apache22/mod_authn_file.so
LoadModule authn_dbm_module libexec/apache22/mod_authn_dbm.so
LoadModule authn_anon_module libexec/apache22/mod_authn_anon.so
LoadModule authn_default_module libexec/apache22/mod_authn_default.so
LoadModule authn_alias_module libexec/apache22/mod_authn_alias.so
LoadModule authz_host_module libexec/apache22/mod_authz_host.so
LoadModule authz_groupfile_module libexec/apache22/mod_authz_groupfile.so
LoadModule authz_user_module libexec/apache22/mod_authz_user.so
LoadModule authz_dbm_module libexec/apache22/mod_authz_dbm.so
LoadModule authz_owner_module libexec/apache22/mod_authz_owner.so
LoadModule authz_default_module libexec/apache22/mod_authz_default.so
LoadModule auth_basic_module libexec/apache22/mod_auth_basic.so
LoadModule auth_digest_module libexec/apache22/mod_auth_digest.so
LoadModule file_cache_module libexec/apache22/mod_file_cache.so
LoadModule cache_module libexec/apache22/mod_cache.so
LoadModule disk_cache_module libexec/apache22/mod_disk_cache.so
LoadModule dumpio_module libexec/apache22/mod_dumpio.so
LoadModule include_module libexec/apache22/mod_include.so
LoadModule filter_module libexec/apache22/mod_filter.so
LoadModule charset_lite_module libexec/apache22/mod_charset_lite.so
LoadModule deflate_module libexec/apache22/mod_deflate.so
LoadModule log_config_module libexec/apache22/mod_log_config.so
LoadModule logio_module libexec/apache22/mod_logio.so
LoadModule env_module libexec/apache22/mod_env.so
LoadModule mime_magic_module libexec/apache22/mod_mime_magic.so
LoadModule cern_meta_module libexec/apache22/mod_cern_meta.so
LoadModule expires_module libexec/apache22/mod_expires.so
LoadModule headers_module libexec/apache22/mod_headers.so
LoadModule usertrack_module libexec/apache22/mod_usertrack.so
LoadModule unique_id_module libexec/apache22/mod_unique_id.so
LoadModule setenvif_module libexec/apache22/mod_setenvif.so
LoadModule version_module libexec/apache22/mod_version.so
LoadModule ssl_module libexec/apache22/mod_ssl.so
LoadModule mime_module libexec/apache22/mod_mime.so
LoadModule dav_module libexec/apache22/mod_dav.so
LoadModule status_module libexec/apache22/mod_status.so
LoadModule autoindex_module libexec/apache22/mod_autoindex.so
LoadModule asis_module libexec/apache22/mod_asis.so
LoadModule info_module libexec/apache22/mod_info.so
LoadModule cgi_module libexec/apache22/mod_cgi.so
LoadModule dav_fs_module libexec/apache22/mod_dav_fs.so
LoadModule vhost_alias_module libexec/apache22/mod_vhost_alias.so
LoadModule negotiation_module libexec/apache22/mod_negotiation.so
LoadModule dir_module libexec/apache22/mod_dir.so
LoadModule imagemap_module libexec/apache22/mod_imagemap.so
LoadModule actions_module libexec/apache22/mod_actions.so
LoadModule speling_module libexec/apache22/mod_speling.so
LoadModule userdir_module libexec/apache22/mod_userdir.so
LoadModule alias_module libexec/apache22/mod_alias.so
LoadModule rewrite_module libexec/apache22/mod_rewrite.so
LoadModule php5_module        libexec/apache22/libphp5.so

<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>

User www
Group www

</IfModule>
</IfModule>

ServerAdmin you@example.com

DocumentRoot "/usr/local/www/apache22/data"


<Directory />
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<Directory "/usr/local/www/apache22/data">

    Options Indexes FollowSymLinks

    AllowOverride None

  
    Order allow,deny
    Allow from all

</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
	DirectoryIndex doku.php index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "/var/log/httpd-error.log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

  
    CustomLog "/var/log/httpd-access.log" combined
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/usr/local/www/apache22/cgi-bin/"

</IfModule>

<IfModule cgid_module>
  
</IfModule>

<Directory "/usr/local/www/apache22/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

DefaultType text/plain

<IfModule mime_module>
  
    TypesConfig etc/apache22/mime.types

    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
</IfModule>

#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type.  The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
#MIMEMagicFile etc/apache22/magic

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it, 
# memory-mapping or the sendfile syscall is used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted 
# filesystems or if support for these functions is otherwise
# broken on your system.
#
#EnableMMAP off
#EnableSendfile off

# Supplemental configuration
#
# The configuration files in the etc/apache22/extra/ directory can be 
# included to add extra features or to modify the default configuration of 
# the server, or you may simply copy their contents here and change as 
# necessary.

# Server-pool management (MPM specific)
#Include etc/apache22/extra/httpd-mpm.conf

# Multi-language error messages
#Include etc/apache22/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
#Include etc/apache22/extra/httpd-autoindex.conf

# Language settings
#Include etc/apache22/extra/httpd-languages.conf

# User home directories
#Include etc/apache22/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include etc/apache22/extra/httpd-info.conf

# Virtual hosts
#Include etc/apache22/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
#Include etc/apache22/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include etc/apache22/extra/httpd-dav.conf


<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

Include etc/apache22/Includes/*.conf
```

Thanks,
Brodey


----------



## pcfxer (Apr 14, 2010)

pcfxer said:
			
		

> I have moved from nginx to Apache only to run into a wall. I have a domain, http://www.potvindover.ca and a redirect dover.homeunix.net. If I use http://www.potvindover.ca I can only see the index.html file, even if I specified /test.php or what have you. The interesting thing is that Apache serves an index.html file out of thin air, because the index.html in my document directory does not have "It Works!" anywhere...
> 
> If I use the redirect I get access to my test.php and my index.html that I have in my directory... Here is my httpd.conf:
> 
> ...



I decided to make a few changes to the ServerName tag...that didn't work

and so I decided to check the permissions on the index.html file in my dir. It was not executable at all so I fixed that up and .....everything works fine now... can you tell me why?


----------



## anomie (Apr 14, 2010)

Are there any .conf files in your apache22/Includes directory? You may have a clever configuration file there that is displaying an "It Works" document in place of what should be an HTTP 404.


----------



## SirDice (Apr 15, 2010)

pcfxer said:
			
		

> and so I decided to check the permissions on the index.html file in my dir. It was not executable at all so I fixed that up and


A html file doesn't need to be executable, neither do any php scripts. You can remove those bits.

Check your DocumentRoot and Directory statements. Also lookup DirectoryIndex.


----------



## trev (Apr 15, 2010)

pcfxer said:
			
		

> I decided to check the permissions on the index.html file in my dir. It was not executable at all so I fixed that up and .....everything works fine now... can you tell me why?



By default apache comes with a bunch of index.html.[lang] files which say "Hey, it worked". I think that explains from where your message came.

It doesn't, however, make sense that adding the executable flag to your index.html file caused it to be called instead. And even a permission problem only causes apache to report that the file is inaccessible. You must have changed your document root?


----------



## pcfxer (Apr 15, 2010)

Okay so, here is what is in my Includes dir.


```
%cat no-accf.conf
<IfDefine NOHTTPACCEPT>
   AcceptFilter http none
   AcceptFilter https none
</IfDefine>
%ls -a
.               ..              no-accf.conf
%
```

The document root tag contains...


```
DocumentRoot "/usr/local/www/apache22/data"
```

..and my Directory Index tag has...


```
<IfModule dir_module>
        DirectoryIndex doku.php index.html
</IfModule>
```

and that is all working and good to go. I do remember ownership of the .html file was root:root, but how in the world of sanity could index.html derive a behaviour that is dependent on the FIRST file specified (doku.php)? I had tried just doku.php as well and that failed miserably.

Now, it is entirely possible that I was extremely tired and screwed up something without realizing it....

I think it is the latter more than the former hehe. 

Thanks for the help guys


----------



## FBSDin20Steps (Apr 16, 2010)

```
<IfModule dir_module>
        DirectoryIndex doku.php index.html
</IfModule>
```

Why don't you use index.php?


----------

