if I just type something to provoke a 404 Error on my Wordpress installation, Wordpress doesn't load its own 404.php file, but the Apache server's own 404 error message gets displayed.

What is wrong with my Wordpress installation? Do I need to edit the Apache server's config file and redirect to the Wordpress 404.php page?


I have partially managed to get this working, I missed the FileInfo directive in the /etc/apache2/sites-available/default file. Not all stuff get caught gracefully, though.

  • Most of the time WordPress can do what you ask automatically. What is the address of a working page? And the address you are using that returns the wrong 404? Is this multisite? – s_ha_dum Mar 26 '14 at 12:47
  • Are you using pretty permalinks? And have you checked that mod_rewrite is enabled & the correct rules are in your .htaccess? – TheDeadMedic Mar 26 '14 at 12:49
  • My installations is at That's the front page of my site. I submit something like and then get redirected to the Apache servers's 404 error message page. – Jaromír the Greenhorn Mar 26 '14 at 12:49
  • I have the default permalink style selected, eg. – Jaromír the Greenhorn Mar 26 '14 at 12:50
  • @TheDeadMedic Where do I check mod_rewrite and .htaccess? – Jaromír the Greenhorn Mar 26 '14 at 12:52

Things are working the way they are supposed to, and possibly the only way they can work. Let me explain.

Without an Apache module called mod_rewrite (or the equivalent Nginx or IIS component) requests to PHP pages have to go to an actual filesystem file. That is what you see with requests like The file being accessed is the directory "index" file-- index.php. That request is the equivalent of What you are doing is requesting some other file/directory with requests like this one-- and no such file or directory exists in the filesystem.

With mod_rewrite and .htaccess properly configured all requests get sent to index.php. Take a look at the stock WordPress .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

That RewriteRule pushes everything (almost everything) to index.php. That allows WordPress to process any request, even requests for files that don't physically exist on the system.

Without pretty permalinks enabled-- that is, with the "default" permalinks selected-- WordPress will not even try to parse the requests so that is equivalent to not having mod_rewrite or .htaccess at all.

And, if WordPress can't parse the request, WordPress can't load the theme's 404.php. Apache, of course, still knows the request is bad and loads its own 404 message.

So, without mod_rewrite, a proper .htaccess file, and pretty permalinks you get the behavior you describe, which is exactly how things are supposed to work.

  • I have enabled mod_rewrite with a2enmode rewrite and created the .htaccess file with the sample content on the Wordpress>Using Permalinks page, but it's still not working out properly. I have noticed that if request server/wordpress/index (no .php) it will redirect to the custom Wordpress 404 page but not if I request something gibberish. – Jaromír the Greenhorn Mar 26 '14 at 13:32
  • By the way, the .htaccess file is in the /var/www/wordpress/ folder is that correct? – Jaromír the Greenhorn Mar 26 '14 at 13:40
  • .htaccess should be in the same directory as wp-load.php usually. That looks right. – s_ha_dum Mar 26 '14 at 13:44
  • Well, I am out of clues, what could be messing up this, I guess having all the files in the subdirectory of /var/wwww/ is not a good idea to host Wordpress. But thanks any way, I will accept your answer as the best, since you have put a lot of effort in this and hope that future users will find it useful in fixing their problem. – Jaromír the Greenhorn Mar 26 '14 at 13:57
  • 1
    "even requests for files that don't physically exist on the system" - technically, the rules only rewrite in this case, hence the RewriteCond's :) – TheDeadMedic Mar 26 '14 at 14:00

WordPress will only handle 404's if pretty permalinks are enabled - go to Settings > Permalinks and choose one of the options other than default (or use your own).

  • I have checked 3 (Day and name, Numeric and Post name) and this doesn't seem to have an effect, i.e. I still get the Apache 404 error message not the 404.php. I am using the Twenty Thirteen theme, by the way. – Jaromír the Greenhorn Mar 26 '14 at 13:01
  • Check out @s_ha_dum's answer, it'll explain things much better! – TheDeadMedic Mar 26 '14 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.