1

I am planning to replace WordPress on my site with custom HTML/CSS/JS, and I'm trying to check my .htaccess file will work. It is working, as I was able to change the directory index with it, but for some reason ErrorDocument 404 /errors/404.html does not work. Instead, when I type a bogus URL, the standard browser 404 message appears.

I have tried just having that line in the htaccess file. I think it may be due to the WordPress folder, which I will delete once the new site is ready. Is this the problem?

  • Where is the WordPress folder? Bare in mind that .htaccess files are inherited, so directives in any parent .htaccess file could be conflicting? – MrWhite Sep 15 '15 at 20:22
  • The WordPress folder is in the same folder as .htaccess – binaryfunt Sep 15 '15 at 21:02
  • "the standard browser 404" - do you literally mean the "browser" 404, as in IE's friendly error page?! Which browsers are you using to test? What server software are you using? Apache I assume? I don't see how the WordPress folder could be affecting this - assuming you're attempting to access a non-existent file outside of this folder. – MrWhite Sep 15 '15 at 21:08
  • I should add that folder is a subfolder - my website is a university club website and there are other websites and folders that I don't have access to. The 404 page that comes up is the default of MS Edge. I'm pretty sure the server is Apache – binaryfunt Sep 15 '15 at 21:11
  • 1
    @closenoc Well the OP is saying they are seeing the "browsers" error page (not the servers). This sounds a lot like IE's old "friendly error page" (didn't realise this was still "a problem" with the latest MS browser though?!). If IE receives an error document that is less than 512 Bytes it will show it's own "friendly" error page - annoying - this can also be turned off in the browser itself. Usual procedure is just to pad the error document with a large HTML comment (if the document is otherwise too small). This is just a hunch, so see what the OP gets. – MrWhite Sep 15 '15 at 21:31
1

the standard browser [MS Edge] 404 message appears.

It would seem you are seeing Internet Explorer / Microsoft's "Friendly HTTP Error Message". This is a feature that is enabled by default in IE (and it would seem Edge) browsers.

If the server response to some common errors (eg. 404, 500, ...) is less than 512 Bytes then IE's "friendly" error page is displayed instead.

If the error document is likely to be less than 512 Bytes then usual procedure is to simply pad the error document with a large HTML comment, to ensure that it is always larger than 512 Bytes!

You can also disable this (per user) in the browser. Under Internet Options > Advanced > Browsing, uncheck the "Show friendly HTTP error messages" option:

IE Internet Options - Show friendly HTTP error messages

Reference:
https://support.microsoft.com/en-us/kb/294807

1

WordPress has own 404 page. It is usually placed in /wp-content/themes/your-active-theme/404.php. The content of 404.php should be at least:

<?php get_header(); ?>

<h2>Error 404 - Page Not Found.</h2>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

If you place your htaccess file IN the Wordpress directory, so the htaccess should contain the line:

ErrorDocument 404 /index.php?error=404

If you place your htaccess BESIDE, on the same directory level, where your WordPress directory is placed, so the htaccess content should be

ErrorDocument 404 /Folder-Name-Of-Wordpress-Installation/index.php?error=404

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.