Support » Networking WordPress » How can I reach ms_site_not_found action?

  • Hi,

    when a subdomain is not found, then wp redirects to the wp-signup.php.
    In that case, I want to load a 404 page instead, without any redirecting, because the redirecting can cause negative seo.

    I found the ms_site_not_found action, and I tried to hook to it, but nothing happened. The hooked function never fires.

    For example in the mu-plugins directory, I wrote that:

    add_action('ms_site_not_found', 'sitenotfound');
    function sitenotfound()

    and the die('111'); line never runs. Nothing runs in this function.

    Can anyone help me, why this action not working?

    If i write a die() line anywhere else in this file, that working, but the function not.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    We already have that covered 🙂 Add this to your wp-config:

    define( 'NOBLOGREDIRECT', '' );

    That’s not good either, that still redirecting, i tried.
    First the core code does a redirect with 302, then got the 404 (my page status).

    The ms_site_not_found action is before the redirecting code, that’s why I wanted to use it.
    I had to hard coded a require_once(…) and exit(), because I didn’t found a proper way to do that.

    How can I use the ms_site_not_found action, or if I used it properly, than why it’s not working?


    I am also interested in this topic.
    NOBLOGREDIRECT only works on subdomain installs, not for subdirectories.


    Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    katazina – You are incorrect that it will cause a problem to SEO. The 302 redirect is the one that SAVES your SEO 🙂 You’re fine. Don’t worry about it.

    schlimpf – That’s because a 404 on a subFOLDER site is just a 404 on the main site 🙂

    So if you install at and go to that’s the same as going to

    There’s no need to use the define.



    For the next person who may end up here trying to figure out why the ms_site_not_found action isn’t firing for them — the docs don’t mention you must bind it in sunrise.php, since none of the plugins (including must-use plugins) have been initialized by the time this action is fired.

    In your wp_config.php, add the define:

    define( 'SUNRISE', 'on' );

    In your sunrise.php file, include:

    function your_function_name($current_site, $domain, $path) {
       die('Site ' . $domain . ' not found.');
    add_action('ms_site_not_found', 'your_function_name', 10, 3);

    Make sure to place sunrise.php in your wp-content folder.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How can I reach ms_site_not_found action?’ is closed to new replies.