0

I want to create a custom 404 page, but I cannot seem to override the 404 which is in Wordpress itself. The reason I want a custom 404 page is that if I get 404 within my subdirectories I get directed to my wordpress-site's 404. I'd rather have a 404 for my whole domain.

I've only found solutions to do this within Wordpress-pages etc, but do I really have to? I guess my problem is the .htaccess-file, however if I mess this one up, my links will be broken on my Wordpress-site.

My .htaccess looks like this (although the first line is the one I want to add, but wordpress doesn't seem to care).

ErrorDocument 404 /404page.php

# 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]
</IfModule>

# END WordPress

In short: My Wordpress-site is on the root of my domain and its 404 page is shown on all subdomains, I want to override this with my own.

  • If you have the other directories in subdomains then wordpress should not have anything to do with them. The setting is not clear please edit and clarify what is your setting and what is the problem – Mark Kaplun Sep 15 '14 at 14:17
  • No, it does not affect my subdomains, but rather my other directories on my domain (where WP is installed on the root). The problem is that my WP's 404 shows, and not my custom when using the .htaccess file posted. I don't want the WP's 404 at all. – PWL Sep 15 '14 at 21:58
1

When a URL is processed by Wordpress, its index.php script is loaded with the path to the requested page. Because in this case the index.php script is always found, a normal 404 error will never trigger (via ErrorDocument 404 …). If the requested URL does not match a page that WP knows about, WP will display its own "404" page.

Unfortunately, if WP processes a URL, there is no way to use a normal 404 page, bypassing the WP 404 page. This issue is documented at https://core.trac.wordpress.org/ticket/7592.

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.