WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#12758 closed defect (bug) (fixed)

Better server checks in network.php

Reported by: nacin Owned by:
Milestone: 3.0 Priority: high
Severity: normal Version:
Component: Multisite Keywords: has-patch needs-testing
Focuses: Cc:

Description

network.php makes careful double-checks (literally) for mod_rewrite in step 1, but nothing in step 2 when it actually presents the rules.

We should be able to detect mod_rewrite in step 2. If they're not running Apache at all, they probably don't need the Apache rules.

Additionally, we need IIS detection and support in both steps.

Attachments (3)

new_iis_rewrite_rules.diff (17.1 KB) - added by Frumph 4 years ago.
Rewrite Rules changes and check for IIS / apache for the network page.
newer_iis_rewrite_rules_404_noblogredirect_fix.diff (17.7 KB) - added by Frumph 4 years ago.
Okay this is all working, subdirectory, subdomain and shows the info in the network panel.
remove-indents.12758.diff (12.1 KB) - added by filosofo 4 years ago.

Download all attachments as: .zip

Change History (30)

comment:1 westi4 years ago

  • Keywords needs-patch added

Frumph4 years ago

Rewrite Rules changes and check for IIS / apache for the network page.

comment:2 Frumph4 years ago

  • Keywords has-patch needs testing added; needs-patch removed

There's just one problem with the .diff is the content portion which i've commented on, otherwise it's working on my end where the network page displays the appropriate rules for.

Another thing it would be nice if I could call the function iis7_url_rewrite_rules from inside of the network.php file, unfortunately I do not know how to call functions inside of a class.

comment:3 Frumph4 years ago

  • Keywords needs-testing added; needs testing removed

comment:4 Frumph4 years ago

  • Keywords needs-patch added; has-patch needs-testing removed

Found some bugs in the url rewrite diff, fixing them now.

comment:5 westi4 years ago

  • Cc ruslany westi added

Please don't do this:

$indent.$indent.$indent

It makes it really hard to read.

Much better to just use a multi-line string.

If this doesn't get a patch in the next couple of days it will likely miss 3.0

comment:6 filosofo4 years ago

Does IIS require indentation for code logic, like Python or something?

comment:7 ruslany4 years ago

No, identation does not affect the IIS runtime. The reason identation is added is so that the rules preview in the Options -> Permalinks page and in the generated configuration file look nice with proper XML indentation.

comment:8 Frumph4 years ago

Well the problem with what I wrote above in that .diff is that the "mainsite" url doesnt transfer 404's, the subsites, mulsitesites off of the main site work just fine.

comment:9 wpmuguru4 years ago

Do we have a patch that works & can be applied?

comment:10 Frumph4 years ago

Alright I figured it out, it's in the wordpress code someplace that the problem is, why? cause this is why.

{{{define('VHOST', 'yes');
If VHOST is 'yes' uncomment and set this to a URL to redirect if a blog does not exist or is a 404 on the main blog. (Useful if signup is disabled)
For example, the browser will redirect to http://examples.com/ for the following: define( 'NOBLOGREDIRECT', 'http://example.com/' );
Set this value to %siteurl% to redirect to the root of the site
define( 'NOBLOGREDIRECT', 'http://frumph.net' );
On a directory based install you must use the theme 404 handler.
}}}
If I uncomment the
define( no blog redirect, which it was it will have the problem where the main site doesnt go to the 404 error page. if I keep it there, the url rewrite rules I wrote above will work fine.

comment:11 Frumph4 years ago

Okay anyways, uncommenting the noblogredirect in the wp-config.php is the issue.

Frumph4 years ago

Okay this is all working, subdirectory, subdomain and shows the info in the network panel.

comment:12 Frumph4 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

comment:13 wpmuguru4 years ago

That all works. The problem we have is that the NOBLOGREDIRECT served a dual purpose of both no blog and 404 redirect. As much as I hate to do it, we're going to have to add another constant.

comment:14 wpmuguru4 years ago

(In [14871]) update rewrite rules for IIS, props Frumph, see #12758

comment:15 wpmuguru4 years ago

To prevent the 404 redirect add

define( 'NO404REDIRECT', true );

I wanted to get the patch in before RC, but the

$indent.$indent.$indent

has to be addressed before closing the ticket.

comment:16 nacin4 years ago

That doesn't get fired until template_redirect, so surely we can use a filter here instead...

comment:17 Frumph4 years ago

What would be best would be the display in the network panel how it displays what to put in the web.config should be generated by the same code that actually does it so it doesn't double up on the information. But that can be an update for 3.1 and I can work on that., for now ron's new define works.

comment:18 filosofo4 years ago

remove-indents.12758.diff is my attempt to make things a little more readable.

comment:19 wpmuguru4 years ago

(In [14885]) cleanup $indents, props filosofo, see #12758

comment:20 follow-up: Frumph4 years ago

You do know the indents were there to make things display properly in the networks panel right?

comment:21 in reply to: ↑ 20 nacin4 years ago

Replying to Frumph:

You do know the indents were there to make things display properly in the networks panel right?

The indents are directly in the strings now.

comment:22 nacin4 years ago

(In [14899]) Use a filter instead of a new NO404REDIRECT constant. see #12758.

comment:23 wpmuguru4 years ago

I;m going to apply another improvement to this one and mark it as fixed. If something shows up re-open the ticket.

comment:24 wpmuguru4 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [14911]) allow main site 404 URL to be filtered, fixes #12758

comment:26 nacin4 years ago

(In [15025]) Add some Apache checks to some notices in network.php. see #12758.

comment:27 nacin4 years ago

(In [15026]) Better branching to account for mod_rewrite mimicry. see #12758.

Note: See TracTickets for help on using tickets.