2

The .htaccess file I have is unable to find my 404.html document in a sub-folder called "error". The line in particular is:

ErrorDocument 404 /error/404.html

However, if I place 404.html in the same directory as .htaccess and change the line to:

ErrorDocument 404 /404.html --- It works!

I'm using XAMPP for Windows if that helps, and in my httpd.conf file, the relevant directives are set as follows (I realize there is some redundancy):

<Directory />
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

<Directory "C:/xampp/htdocs">
    Options Indexes FollowSymLinks Includes ExecCGI MultiViews
    AllowOverride All
    Require all granted
</Directory>

Also, my DocumentRoot is set to "C:/xampp/htdocs", and I'v tried various paths to access the "error" directory--none work:

ErrorDocument 404 /error/404.html
ErrorDocument 404 /flchi/error/404.html
ErrorDocument 404 /sites/flchi/error/404.html
ErrorDocument 404 /htdocs/sites/flchi/error/404.html

Oh, and one final thing for what it's worth--I'm using virtual hosts. Here's the relevant bits:

<VirtualHost *>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
    ServerAlias localhost
    <Directory "C:/xampp/htdocs">
        Options Indexes FollowSymLinks Includes ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost flchi.local>
    DocumentRoot "C:/xampp/htdocs/sites/flchi"
    ServerName flchi.local
    ServerAlias flchi.local
    <Directory "C:/xampp/htdocs/sites/flchi">
        Options Indexes FollowSymLinks Includes ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
Sparx401
  • 55
  • 2
  • 7
  • What's the absolute path of the file `404.html` you're trying to use, and in which directory is your `.htaccess` ? – Cozzamara Jan 21 '13 at 00:53
  • The absolute path of 404.html: "C:/xampp/htdocs/sites/flchi/error/404.html". The directory that .htaccess is in is: /flchi. – Sparx401 Jan 21 '13 at 01:07

1 Answers1

4

This happens because of naming conflict - default Apache configuration already defines virtual path for /error, affecting all virtual hosts globally. It's done in config file xampp/apache/conf/extra/httpd-multilang-errordoc.conf. Location /error, therefore shadows your /error subdirectory:

  Alias /error/ "C:/xampp/apache/error/"

It should work if you rename your 'error' sub-directory to something else - for example, error2.

   ErrorDocument 404 /error2/404.html
Cozzamara
  • 1,318
  • 1
  • 14
  • 22