WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] MultiSite 404 main domain not working (4 posts)

  1. BackuPs
    Member
    Posted 2 years ago #

    Hi Guys,

    I installed multisite with the subdomain option and not the sub directory.

    I also created the *(asterix) subdomain. Now i have the following problem.

    When i call a page in the main domain which does not exist the call is rerouted to the main domain index page and no 404 is issued.

    However if i do the same on one of the subdomains the 404 on the same theme is issued perfectly.

    Is this a bug in wordpress MultiSite?

    Looking forward to your reply,

    Best regards,
    BackuPs

  2. BackuPs
    Member
    Posted 2 years ago #

    Hmm i solved my own problem.... It was a pitfall caused by turning on the NOBLOGREDIRECT.

    Turning off Allow users to create a subsite.

    WPMS (wordpress multisite) has a cool feature that new users can create new website. So if they search for helloworld.maindomain.com and this one does not exist they are redirected to some nice signup page for creating the newly blog helloworld.

    However if you do not want this you can disable this and your adviced to put a line in your wp-config.php redirecting users instead of the create new blog screen to the main index of the main domain or any other page within that website..... except the 404. The line to add is define( 'NOBLOGREDIRECT', 'http://maindomain.com' );

    But this means that when a page does not exist and a 404 should be generated the 404 is also never reached. So you 404 is disabled by this instructions. It took me some time to figure this out and to solve it.

    The solutions is pretty simple. Just create a folder in your wp-content called : mu-plugins

    in the mu-plugins you just insert a php file name custom.php with this content. Or whatever name

    <?php
    remove_action( 'template_redirect', 'maybe_redirect_404' );
    ?>
    

    Now what happens is that users who call a blog that not exists get redirected to the root of the main domain to the index.php and really 404's are handled like they should be handled.

    so that one is solved and can be taken of the list.

    Best regards,
    BackuPs

  3. AMFinzel
    Member
    Posted 2 years ago #

    I just wanted to say that your solution worked for me; thank you! I was looking high and low and was about to post my own thread on the subject.

  4. stormymondays
    Member
    Posted 2 years ago #

    Thanks! I spent hours trying to figure out why my .htacess code to rewrite the non-www version to www wasn't working. This cured it!

    With your solution:

    1. I can have non-www redirect to www:

    RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

    2. 404 pages work correctly in the main domain of the multisite install.

    3. I don't get the new network site signup page, which I don't need.

    :)

Topic Closed

This topic has been closed to new replies.

About this Topic