WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#13089 closed defect (bug) (duplicate)

WPMU blogs.php rewrite rule fails when URL has query string

Reported by: RavanH Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.9.2
Component: Multisite Keywords: needs-patch
Focuses: Cc:

Description

This came up in WPMU 2.9.2 using the plugin eShop that places a css file in a subfolder of a blogs upload file folder and then adds it to the page source using wp_enqueue_style ... this results in a stylesheet URL that has a version number appended like .css?ver=n

Normally this poses no problem but since the file is stored under the blog specific blogs.dir and is called via /files/eshop_files/eshop.css?ver=123 (for example) the call gets caught by the .htaccess rule:

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

Now suddenly the question mark (?) in the URI becomes a problem!

Live example:
http://downloads.free-jazz.net/files/eshop_files/eshop.css
versus
http://downloads.free-jazz.net/files/eshop_files/eshop.css?ver=0.1

But it also applies to any other common image, for example:
http://downloads.free-jazz.net/files/1986/05/3791543494_a38c5e7eaa_o-150x150.jpg
versus
http://downloads.free-jazz.net/files/1986/05/3791543494_a38c5e7eaa_o-150x150.jpg?ver=1

Proposed fix:
Replace .htaccess rules with

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]

RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteCond %{REQUEST_URI} .*files/.*
RewriteCond %{QUERY_STRING} !^$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1? [L]

RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

This makes the query string being stripped from the URL before the final rewrite to blogs.php?file=... is applied.

Change History (4)

comment:2 @nacin5 years ago

  • Component changed from General to Multisite
  • Milestone changed from Awaiting Review to 3.1

comment:3 @nacin5 years ago

  • Keywords needs-patch added; wpmu blogs.php htaccess removed

Needs a formal patch. Also for IIS if it affects that.

comment:4 @nacin4 years ago

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

Pretty sure this is a duplicate of #14450. Apache should be able to handle that.

Note: See TracTickets for help on using tickets.