WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 23 months ago

#13689 closed defect (bug) (duplicate)

multisite noblogredirect set, 404 error result not sending proper info with IIS

Reported by: Frumph Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Multisite Keywords:
Focuses: Cc:

Description

Scenario. With NOBLOGREDIRECT specified as the main sites url, the 404 errors and the bad blog url are supposed to go what is specified as the location in the noblogredirect define.

The bug is the 404 errors are *not* pointing to what is specified in the noblogredirect, the 404 errors (that are not bad blog urls) are triggering an IIS error response and not redirecting.

When it's done triggering the IIS error it then uses the web.config to transfer to the main site.

Besides this bug.

This tells me 2 things, this tells me that the method/behavior of this is wrong and should be looked at. *if* wordpress knows the difference between a bad blogurl and a 404 error page, the 404 error *should* go to the 404 template, however in the past WPMU versions it did not do that it went straight to the mainsite as well. It *should* go to the 404 template and since it knows the difference it should be coded a such.

1) Bad subdomains should go to the specified noblogredirect define.
2) 404 error pages should go to the 404 page template for the theme.

Not to mention that the bug in question *is* that the 404 error itself is not redirecting to it's intended location to begin with.

Attachments (1)

maybe_blog_redirect_removal.diff (1.2 KB) - added by Frumph 5 years ago.

Download all attachments as: .zip

Change History (32)

comment:1 @nacin5 years ago

Is this an MU regression?

comment:2 @Frumph5 years ago

This is a bad behavior situation.

I figured it out after spending a few hours on it

function maybe_redirect_404() is not needed, .. at all. It's the cause of the situation, and let me explain in a little detail.

Now the actual *problem* with it is that since it's using the is_404() check right there and the user has NOBLOGREDIRECT set, all 404 errors get captured right there and get sent to the NOBLOGREDIRECT, the behavior should be that the 404 pages get sent to the 404 error page regardless; however, since it's being captured/used there there's no chance for it to hit it with NOBLOGREDIRECT defined.

On my IIS system for some reason with the 404 error pages (not bad sites) the wp_redirect is sending a blank $destination to it.

If I completely remove maybe_redirect_404() and it's filter call for it *everything* works in multisite, the behavior is appropriate.

On SubDirectory installations:
404 errors redirect to the 404 page. /baddirectory calls redirect to 404 page.

OnSubdomain installations:
(without) NOBLOGREDIRECT
# 404 errors go to the 404 error page
# wrong subdomains go to the signup page properly

(with) NOBLOGREDIRECT
# 404 errors go to the 404 error page
# wrong subdomains go to the destination set in NOBLOGREDIRECT

This is *without* the maybe_redirect_404(). At some point I'm sure the function existed with WPMU to handle *some* situation at one point or another but it's not needed now.

This information needs confirming of course but on my system here it's detrimental to have it exist and have the multisite's behave properly.

comment:3 @Frumph5 years ago

  • Cc philip@… added

comment:4 @westi5 years ago

  • Keywords iis-support added; Multisite Subdomain 404 removed

comment:5 @ryan5 years ago

Does it work without [14911]?

maybe_redirect_404() has been in MU for awhile.

comment:6 @Frumph5 years ago

14899 Fixed it (sort of a quick-patch), 14911 broke it again. but neither of them handled the is_404 being captured and processed right there.

comment:7 @Frumph5 years ago

Right maybe_rediect_404() was probably used for a certain situation only as a quick fix to handle the processing of noblogredirect with the way the wpmu was processing its requests. However, with all the changes to WP since then it's possible that it's no longer needed.

comment:8 @Frumph5 years ago

Sorry this started with a fix in #14871

comment:10 @wpmuguru5 years ago

This works the same as MU did (excepting the filter offers a means of turning the 404 handling off).

If some other IIS installs could confirm this causes a problem with their IIS as well then the filter could be removed when running IIS.

comment:11 @Frumph5 years ago

.. It's not the filter. It's the behavior.

Just doing

`
function maybe_redirect_404() {

global $current_site;
if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) ) {

$destination = NOBLOGREDIRECT;
if ( $destination == '%siteurl%' )

$destination = network_home_url();

wp_redirect( $destination );
exit();

}

}
`

Will cause the same bad-behavior.

comment:12 @memitch085 years ago

I'm experiencing the same problem, and removing the maybe_redirect_404 does not fix the problem? It still redirects to the site 404 page - not the WP 404 page?

I've tried all of the fixes suggested.

comment:13 @Frumph5 years ago

@memitch08 server stats and setup stats if you could, 3.0 multisite (isapi/cgi/fastcgi) subdomain or subdirectory install, 404 page is triggered when inputting bad subdomain or 404, using noblogredirect?

comment:14 @memitch085 years ago

Server is IIS 6
3.0 RC2 multisite
subdirectory install
(also installed into a subdirectory shapingdestiny.org/celebrate)

404 page is triggered on pages, posts, and sites other than the main site.

Thanks!


comment:15 follow-up: @Frumph5 years ago

@memithc08 sounds like you're using the old web.config back up your current one and regenerate a new one with settings->permalinks

comment:16 in reply to: ↑ 15 ; follow-up: @memitch085 years ago

Replying to Frumph:
I'm building a website for someone - and only have FTP access. I'm not the most savvy when it comes to these things. Can I generate a new web.config file from FTP or do I need to do it through the control panel? Thanks!

comment:17 in reply to: ↑ 16 @memitch085 years ago

Replying to memitch08:

Replying to Frumph:

I don't see a web.config file anywhere in any of the directories.

comment:18 follow-up: @Frumph5 years ago

SOrry dude, you're going to have to talk to the hosting he's on and check what URLRewrite method it implements. If at all. with IIS6 it was rarely if ever used.

comment:19 in reply to: ↑ 18 @memitch085 years ago

Replying to Frumph:
Thanks for the help. If I set the permalink structure to Default - everything works ok, but anything else is 404 - so the problem is with the host! Thanks again and sorry!

comment:20 @Frumph5 years ago

@wpmuguru the 404 issues with the redirect were caused by the web.config needing some rule fixing.

However that doesn't escape the bad behavior of the maybe function capturing the 404 at that point. There's no purpose to have the 404 errors reroute to the mainsite with noblogredirect on when the system can clearly handle knowing the difference (now) between a bad domain and a 404.

I'm sure for whatever reason there was with WPMU, but it's not necessary now.

comment:21 @Frumph5 years ago

spoke too soon on the 404 with this one, i still haven't gotten the web.config to avoid it

comment:22 @Frumph5 years ago

http://ruslany.net/2010/03/important-update-for-iis-7-0-fastcgi-module/

Hotfix for fastcgi fixed the issue with the 404, *thanks ruslany*

So let's get back to the topic of the bad behavior for it not directing to the 404 error page on 404 instead of it redirecting to the noblogredirect.

comment:23 @Frumph5 years ago

  • Milestone changed from 3.0 to Future Release

comment:24 @ruslany5 years ago

  • Cc ruslany@… added
  • Keywords iis-support removed

There are two issues described in this bug:

  1. IIS displaying generic IIS 404 error instead of a custom WordPress 404 error. This issue is fixed by applying the FastCGI hotfix that can be found here (http://ruslany.net/2010/03/important-update-for-iis-7-0-fastcgi-module/).
  1. NOBLOGREDIRECT is used for bad URL's on the main site instead of a main site's 404 web page. Is this an incorrect behavior or is this by design? This is caused by the maybe_redirect_404() function and it looks to me that it has been like this for a while. Note that this issue is not specific to IIS.

I would suggest to change the title of the ticket to reflect that this is to track the second issue.

comment:25 follow-up: @peaceablewhale5 years ago

  • Keywords dev-feedback added

Need dev-feedback on the behavior of NOBLOGREDIRECT.

comment:26 in reply to: ↑ 25 @wpmuguru5 years ago

  • Keywords dev-feedback removed

Replying to ruslany:

  1. NOBLOGREDIRECT is used for bad URL's on the main site instead of a main site's 404 web page. Is this an incorrect behavior or is this by design? This is caused by the maybe_redirect_404() function and it looks to me that it has been like this for a while. Note that this issue is not specific to IIS.

It does that by design. In a subfolder install, if no sub-site matches the request WordPress (and before that MU) cannot tell whether it's a request for a non-existent sub site or a request for a non-existent page on the main site. So, one function served by the 404 handling is to provide consistent handling.

Secondly, the main site is the default site which handles all requests WordPress that fail a sub-site lookup. After failing sub-site lookup, the buck stops at a 404 on the main site.

The NOBLOGREDIRECT allows a super admin to direct those requests to something other than a 404 through the main site. There is no requirement to have a NOBLOGREDIRECT defined.

comment:27 @Frumph5 years ago

I'm done fighting with you about it, it's stupid and needs to be removed.

http://frumph.net/wordpress/wordpress-3-0-multisite-subdomain-installation-noblogredirect-behavior-fix/

Here's a fix for anyone interested in removing this bad-behavior.

comment:28 @markoheijnen3 years ago

  • Cc marko@… added

I do believe the functionality is needed but it does need some extra check.

When you have a subdomain install there is a big change you do want to use NOBLOGREDIRECT but you don't want that 404 on the main site will redirect. You want to have a 404 there since the change is to little there would be a subsite.
It's also weird to have different behavior on the main site then the other sites.

comment:30 @SergeyBiryukov3 years ago

  • Component changed from General to Multisite

comment:31 @jeremyfelt23 months ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Closing this as a duplicate of #21573 to clear things up a bit.

The original ticket was opened with a combination of issues.

  1. An IIS related issue that was resolved outside of WordPress, see comment 22.
  2. A question of behavior with maybe_redirect_404() and NOBLOGREDIRECT

#21573 is more clear in its description of the second point.

Note: See TracTickets for help on using tickets.