Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#15083 closed defect (bug) (fixed)

Apache rewrite loop on subdirectory install

Reported by: wpmuguru's profile 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 13 years ago.
15083.refactoring-first.patch (2.9 KB) - added by hakre 13 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 13 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 13 years ago.
Moved some more code into functions.
mylyn-context.zip (191.4 KB) - added by hakre 13 years ago.
mylyn/context/zip

Download all attachments as: .zip

Change History (13)

@wpmuguru
13 years ago

#1 @wpmuguru
13 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.

#2 @wpmuguru
13 years ago

  • Description modified (diff)

#3 follow-up: @hakre
13 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?

@hakre
13 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)

@hakre
13 years ago

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

@hakre
13 years ago

Moved some more code into functions.

@hakre
13 years ago

mylyn/context/zip

#4 in reply to: ↑ 3 @wpmuguru
13 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.

#5 follow-up: @nacin
13 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.

#6 in reply to: ↑ 5 @wpmuguru
13 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.

#7 @nacin
13 years ago

Also applied to IIS.

#8 @nacin
13 years ago

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