Make WordPress Core

Opened 10 years ago

Closed 9 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:


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:

But it also applies to any other common image, for example:

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)

#2 @nacin
10 years ago

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

#3 @nacin
10 years ago

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

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

#4 @nacin
9 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.