[wp-trac] [WordPress Trac] #13089: WPMU blogs.php rewrite rule fails when URL has query string

WordPress Trac wp-trac at lists.automattic.com
Thu Apr 22 23:07:36 UTC 2010


#13089: WPMU blogs.php rewrite rule fails when URL has query string
--------------------------+-------------------------------------------------
 Reporter:  RavanH        |       Owner:                         
     Type:  defect (bug)  |      Status:  new                    
 Priority:  normal        |   Milestone:  Unassigned             
Component:  General       |     Version:  2.9.2                  
 Severity:  normal        |    Keywords:  wpmu blogs.php htaccess
--------------------------+-------------------------------------------------
 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.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13089>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list