WordPress.org

Ready to get started?Download WordPress

Forums

Custom 404 error page (3 posts)

  1. itmdesign
    Member
    Posted 5 years ago #

    Hi,

    I have wordpress installed on my website and currently when a user gets a 404 error it redirects to the 404 message in the blog.

    I'd like to have the 404 page outside of the blog in a file called notfound.php but my attempts so far have just broken the blog.

    Can anyone help me with the .htaccess code required please.

  2. itmdesign
    Member
    Posted 5 years ago #

    Sorted this now.

    WordPress already has it set up to go to a 404.php file so I just edited that with the code I wanted.

  3. thinkstorm
    Member
    Posted 5 years ago #

    Not quite: if you call http://www.playoutintelligence.com/asdasdasdasd, the 404 page will not redirect to http://www.playoutintelligence.com/404.php

    Maybe it's also possible to check in the root index.php file whether is_404(), and then call <?php header("notfound.php", true, 404); ?>

    The reason why I suggest to look at the root index.php is that I'm not sure if you can call the header(..) function anywhere within a page. If I remember correctly, this has to happen before the <html> tag is written...

    I would, however, definitely recommend using 404.php if the name of the URL is not important to you...

    Cheers, Thorsten

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags