WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 3 years ago

#15083 closed defect (bug) (fixed)

Apache rewrite loop on subdirectory install

Reported by: wpmuguru Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version:
Component: Multisite Keywords: has-patch commit
Focuses: Cc:

Description (last modified by wpmuguru)

If a requested file under the wp-content directory does not exist, this creates a rewrite loop for the file. Let's say /subsite/wp-content/themes/theme-x/images/abc.gif does not exist, then the rewrite that is invoked is:

RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]

The first rewrite pass rewrites the url to /wp-content/themes/theme-x/images/abc.gif which also does not exist. However, the rewritten request still matches the rewrite rule because the question mark ^([_0-9a-zA-Z-]+/)? makes it so the rewrite rule also applies to /wp-content/themes/theme-x/images/abc.gif.

Attachments (5)

15083.diff (613 bytes) - added by wpmuguru 4 years ago.
15083.refactoring-first.patch (2.9 KB) - added by hakre 4 years ago.
Seperatred Concerns first by refactoring htaccess content generation into a function of it's own and by using template variables instead of mixing template and code (at least a bit more than previsously)
15083.refactoring-first.2.patch (2.9 KB) - added by hakre 4 years ago.
First Patch had some bugs, fixed. Changed Regexes according to description now.
15083.refactoring-first.3.patch (15.9 KB) - added by hakre 4 years ago.
Moved some more code into functions.
mylyn-context.zip (191.4 KB) - added by hakre 4 years ago.
mylyn/context/zip

Download all attachments as: .zip

Change History (13)

wpmuguru4 years ago

comment:1 wpmuguru4 years ago

I don't have IIS to work with so I did not patch those rules. If someone with IIS could makes similar changes to the IIS rules, that would be great.

comment:2 wpmuguru4 years ago

  • Description modified (diff)

comment:3 follow-up: hakre4 years ago

I smells like the ? is needed for the /. And then while taking a look in the code: What about the uploaded files? Don't they have the same pattern that you're about?

hakre4 years ago

Seperatred Concerns first by refactoring htaccess content generation into a function of it's own and by using template variables instead of mixing template and code (at least a bit more than previsously)

hakre4 years ago

First Patch had some bugs, fixed. Changed Regexes according to description now.

hakre4 years ago

Moved some more code into functions.

hakre4 years ago

mylyn/context/zip

comment:4 in reply to: ↑ 3 wpmuguru4 years ago

Replying to hakre:

I smells like the ? is needed for the /. And then while taking a look in the code: What about the uploaded files? Don't they have the same pattern that you're about?

No, the ? is not needed for the /. The rewrite base is / (or /path-to-wp-install/), so in /subsite/wp-content/... what is being rewritten is subsite/wp-content/...

In contrast, the /files rewrite has to be processed whether or not there is a leading subsite path which is why I did not change it.

comment:5 follow-up: nacin4 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 3.1

wpmuguru -- this looks valid. No reason to try to redirect the root blog (which was the point of the ?) because /wp-load.php will exist, and we're only looking for files that are virtual like /subsite/wp-load.php.

Should be good on http://core.trac.wordpress.org/attachment/ticket/15083/15083.diff.

comment:6 in reply to: ↑ 5 wpmuguru4 years ago

Replying to nacin:

wpmuguru -- this looks valid. No reason to try to redirect the root blog (which was the point of the ?) because /wp-load.php will exist, and we're only looking for files that are virtual like /subsite/wp-load.php.

exactly.

comment:7 nacin3 years ago

Also applied to IIS.

comment:8 nacin3 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.