Mladen
Mladen

Reputation: 675

custom 404 error htaccess doesn't work on apache 2

I've tried doing this with a .htaccess file on Apache and just couldn't get it to redirect to a custom 404 page. It would just keep on using the default apache 404 page.

This is what I've done:

I've put .htaccess file and a custom 404 file (page-not-found.php) into my home directory where index.php is.

This is the line that's in .htaccess file: ErrorDocument 404 /page-not-found.php

I also tried the full document path: ErrorDocument 404 /var/www/htdocs/page-not-found.php

I've made sure that in '/etc/apache2/sites-enabled/default' and '/etc/apache2/sites-available/default' 'AllowOverride' is set to 'All' as below:

    <Directory /var/www/htdocs/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

I made sure that AccessFileName in httpd.conf is .htaccess

I restarted apache after every change.

None of this made it work, it still uses the default apache 404 file. Anoying thing is that this worked on a vritual site on the same server, but wouldn't work on the default site. Separate but same issue: I also can't get it to work on localhost on my own pc.

(Arggghhhhhhh!!!!!!!!!!)

What am I missing?

Upvotes: 0

Views: 2447

Answers (1)

Stephen
Stephen

Reputation: 3737

have you enabled the mod ?

 sudo a2enmod rewrite

you will need to restart apache again after installing

Upvotes: 0

Related Questions