0

I have a .htaccess file in /var/www, the contents of which is:

ErrorDocument 404 /404.html

In apache2.conf AccessFileName is .htaccess, and AllowOverride does not exist. For some reason, visiting example.com/anything does not show 404.html.

MrWhite
  • 11,643
  • 4
  • 25
  • 40
JJJollyjim
  • 265
  • 2
  • 4
  • 12
  • "and `AllowOverride` does not exist" - does not exist _anywhere_ in the server config? The default setting on Apache 2.2 is `AllowOverride All`, however, `AllowOverride None` is often defined in the main server config to disable `.htaccess` for the server. – MrWhite Aug 26 '20 at 22:13

1 Answers1

1

You will need to configure a suitable AllowOverride setting in your configuration file to get ErrorDocument to work. The override you require is fileinfo e.g.

<Directory /var/www/>
    .
    .
    .
    AllowOverride fileinfo 
 </Directory>
user9517
  • 114,104
  • 20
  • 206
  • 289
  • I added: ` AllowOverride ALL ` to apache2.conf (there was no directory thing already). And it made no difference. – JJJollyjim Mar 23 '11 at 08:13
  • @JJ56: Ok, that was an example because I don't know your configuration. You should put the AllowOverride directive within the Directory block that makes sense to your configuration. Don't forget to restart you Apache too. – user9517 Mar 23 '11 at 08:22
  • Where is the directory block? There is none in ports.conf, apache2.conf, or httpd.conf. I added the one to apache2.conf, but 404 still dosen't work. – JJJollyjim Mar 23 '11 at 08:27
  • @JJ56: Which OS/distro are you using ? – user9517 Mar 23 '11 at 08:29
  • ubuntu server edition 10.10 – JJJollyjim Mar 24 '11 at 01:47
  • all i really know about my apache configuration is that i used "tasksel --section-server" and chose LAMP server. – JJJollyjim Mar 24 '11 at 01:49
  • @JJ56: Ubuntu splits the httpd configuration across several files. You should find the configuration you need to change in`/etc/apache2/sites-enabled/000-default`. – user9517 Mar 24 '11 at 07:06