The MU forums have moved to

404 goes to the create a new blog page! (23 posts)

  1. roguestar
    Posted 16 years ago #

    404 goes to the create a new blog page how can i change it to go to where i want it to?

  2. roguestar
    Posted 16 years ago #


  3. irinazaks
    Posted 16 years ago #

    did you have any luck figuring it out? I have the same problem.


  4. drmiketemp
    Posted 16 years ago #

    1) Please make sure that you;ve read the readme.txt file included with the download. You probably missed something within it.


  5. lunabyte
    Posted 16 years ago #

    Sure doesn't give much information to work with here.

    What kind of 404? Can you give an example?

    If it's a blog which doesn't exist, yes, it will go to the sign-up page.

  6. drmiketemp
    Posted 16 years ago #

    Luna, just for reference, I added "Give an example" to the debugging page along with some other stuff.

  7. lunabyte
    Posted 16 years ago #

    Ah, okie dokie Doc.

    Makes sense, really. Nice catch. ;)

  8. SekJal
    Posted 16 years ago #

    My team and I noticed this as well; when a user enters an invalid URL (that is, a URL with no blog or server directory associated with it), they are redirected to wp-signup.php, and prompted to create a new user account and blog based on the URL they entered.

    Example: redirects to

    We modified wp-signup.php to meet our needs (allow user signup, but not blog signup). We also found where the redirect is coded in WPMU: wpmu-settings.php, around line 105, within the IF statement. We removed the redirect.

    Doing so prevented 404 errors from redirecting to wp-signup.php. But now, all 404 errors simply give us a blank page (no HTML code whatsoever).

    We added a line to .htaccess that will handle 404 errors for particular files (ex: However, we still get a blank page for invalid directories (ex:

    I've tried several .htaccess lines before realizing that modifying .htaccess could not fix the problem. This is because Apache does not know the difference between a valid blog URL and an invalid URL, since blog URLs are dynamically generated by WPMU.

    So, our problem now reduces to finding the proper place in the code to insert a 404 header. Since .htaccess's last-ditch command is to summon index.php, that seems like the best place to start... however, I quickly get lost in the code once I follow the function calls from there.

    Does anyone know where I should look?

  9. lunabyte
    Posted 16 years ago #

    You should have just left the signup redirect code in place, and instead redirected to a custom 404 page.

  10. SekJal
    Posted 16 years ago #

    That was a possibility, but we wanted to preserve the invalid URL in the address bar. This maintains consistency without our entire website (no other pages redirect upon a 404), and lets the user see what the typed (easier to spot a mistake).

    This is, fortunately, a non-essential modification, so we're in no rush to complete it. But I will continue to search for the proper place to insert the 404 header in the WPMU code, and relay my findings for anyone interested.

  11. lunabyte
    Posted 16 years ago #

    Well, that would still be the area to interject.
    You could instead set the page template as 404, and have the url be the same.

    Look into using the $wp_query object, and then adding an action to template_redirect, and setting the 404 template.

  12. Haythoo
    Posted 16 years ago #

    I have the same problem with all links in all post!!

    anyone click on the post title, the link take him to the sign-up page!!

  13. Haythoo
    Posted 16 years ago #

    could any one help? :(

  14. SekJal
    Posted 16 years ago #

    lunabyte: Thank you for the guidance. I'll start investigating/coding on that this week.

    Haythoo: I think I've seen this problem elsewhere in the forums. Are your directories appropriately writable? What does your .htaccess look like? I remember having a similar problem, doing some research, and finding a solution pretty quickly.

  15. Haythoo
    Posted 16 years ago #

    Hi SekJal

    This is the .htaccess

    RewriteEngine On
    RewriteBase /

    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    and the dir permission is 750

    the problem come after I moved to 1.3

    also I had problem with language and I fix it.

  16. SekJal
    Posted 16 years ago #


    I looked again at what you said about using $wp_query and using template_redirect. I gave it a go, but unfortunately, the combination of the elements is not clear to me.

    It seems like that if I want to preserve the wrong URL in the address bar, I should remove the redirect. Should I replace it with an add_action('template_redirect', 'my_404_function'), or do all of that in a plugin? I can't seem to access the global $wp_query variable in wpmu-settings.php, which makes me think I need to be working mostly in my plugin file. I would probably have to mimic the conditional statements that wrap the redirect currently in order to get it all to work at the right times.

    Thanks for your help!

  17. kic00
    Posted 16 years ago #

    I have a similar issue; I don't want all 404s to redirect to the signup page, I just want them to 404. Missing images and other filetypes can be coded into .htaccess, but it seems like an inelegant solution.

    I changed the signup redirect code per Lunabyte's suggestion above, but is there no way to have the HTTP header return as a 404? There are lots of good reasons to do so -- robots, for example, and other scripts, look for the correct HTTP header.

  18. SekJal
    Posted 16 years ago #

    After much staring at the code, I think I found a creative workaround to the problem.

    In the code section immediately above the troublesome redirect, WPMU figures out which blog you are attempting to reference with the given URL. It parses out the first directory after the $current_site, and calls this $blogname. For an installation at the root of, the URL would assign $blogname = wrong.

    If $blogname is null, a keyword (wp-content, wp-admin, blog, etc.), a file, or a page in the root blog, we must be looking for the root blog.
    Otherwise, the grab whatever blog exists at {$current_site->domain}{$current_site->path}{$blogname}, and assign it to $current_blog.

    In the case of a 404 error, $blogname doesn't point us to a valid blog in the database (the variable $current_blog is set to null). WPMU's native function is to present us with an option to then create a new blog named $blogname whenever $current_blog is null. This brings us to the problem at hand.

    My solution, then, is to remove the following code around line 110 of wpmu-settings.php:

    header( "Location: http://{$current_site->domain}{$current_site->path}wp-signup.php?new=" . urlencode( $blogname ) );

    and replace it with this:

    $current_blog = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE domain = '$domain' AND path = '$path'");

    Now when we check and find $current_blog is null, we reassign $current_blog to the root blog. The system will use its pre-existing page templating methods to summon the 404 template in the current theme for the root blog, and whenever we put in a bad URL, we'll get a nice, customizable 404 error page.

    Hopefully this will be of use to others who wish to prevent a redirect to the sign-up page. Please, if you find any unpleasant side effects to this solution, post them here so I can try to fix them.

  19. theapparatus
    Posted 16 years ago #


    Not sure what version of mu you're using but this is now a variable that you can hard code in:

  20. cclinton
    Posted 16 years ago #

    I see your hard code this something that will be taken care of in the next version of MU or will we have to remember to perform this action again after we update in the future?

  21. cclinton
    Posted 16 years ago #

    Sorry, I just added a new wpmu system and checked the files. It appears that these were already added to the latest files.
    So, here's my problem: it still occurs.

    When I enter a bad link just after the domain name (example: I am sent to the signup page (example: However, if I enter a bad link after an existing directory (example: you are provided with a page using the 404 template included with the theme.

    Is there a way to rectify this?

    I am using the latest version of MU (downloaded yesterday) and have my misc blogs set up as subdirectories rather than subdomains.

  22. KKWangen
    Posted 16 years ago #

    You need to see an url in define( 'NOBLOGREDIRECT', '' );


    define( 'NOBLOGREDIRECT', 'http://mysite.tld/404/' );

    At least that worked for me.

  23. nibb
    Posted 16 years ago #

    Hi guys,
    I've read this thread with interest, have the same problem in that if

    a) I dont set a page in NOBLOGDIRECT I get some junk page being created with wp_signup instead of a 404 error (this only occurs if the page requested looks like a directory - in other words just type a pile of junk at the end of the URL you know to work and it fires this error situation off)

    b)setting a site in NOBLOGDIRECT (for quick test I used a totally different URL - the BBC news pages), the site itself isn't redirected to - I get the signup for a blog page - which I definitely do not want to occur.

    Anyone any ideas?

    In addition, I notice that if I try this sort of error out on a 'subdomain' or a sub-blog - I get an apache delivered 404 error referenced off the main domain name: - e.g.

    Main site is


    Blog creation page is found if I ask for:

    If I try the sub blog

    with any erroneous request:-


    I get a 404 error generated by Apache for


    Surely some stupid redirects going on here. How are these matters handled on

    best wishes and thanks:

About this Topic