Opened 16 years ago
Closed 15 years ago
#13089 closed defect (bug) (duplicate)
WPMU blogs.php rewrite rule fails when URL has query string
| Reported by: |
|
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.
http://core.trac.wordpress.org/ticket/11315