WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Creating a network-wide 404 page (2 posts)

  1. Cyrolancer
    Member
    Posted 2 years ago #

    Greetings!

    I want to create a network-wide 404 page, regardless of the template of the user's blog. All 404 errors should redirect to the custom 404 page.

    According to my research on WP Codex, I need to create a 404 page for all themes. In my network, there are a lot of themes and I am searching a way to redirect all 404 errors to my custom 404 page (ex: my-site.com/404.php) without touching any template file.

    How can it be possible?

    Thanks

  2. Cyrolancer
    Member
    Posted 2 years ago #

    Hello again,

    I think I have found a solution. I will explain step by step.

    1. I have created wp-content/mu-plugins/custom-functions.php

    2. I have added the following:

    function check404() {
        if(is_404())
            header('Location: /404.php');
    }
    
    add_filter('404_template', check404);

    inside custom-functions.php file.

    3. I have created 404.php in the site root.

    That is so easy. Sorry for my "post pollution" in the forum.

Topic Closed

This topic has been closed to new replies.

About this Topic