[wp-trac] [WordPress Trac] #20746: Accessing non-existing theme folder in Network install gives 500 error

WordPress Trac noreply at wordpress.org
Wed Aug 5 21:55:42 UTC 2015


#20746: Accessing non-existing theme folder in Network install gives 500 error
---------------------------------------+-----------------------------
 Reporter:  arkimedia                  |       Owner:
     Type:  defect (bug)               |      Status:  reopened
 Priority:  normal                     |   Milestone:  Future Release
Component:  Rewrite Rules              |     Version:  3.3.2
 Severity:  normal                     |  Resolution:
 Keywords:  needs-testing needs-patch  |     Focuses:  multisite
---------------------------------------+-----------------------------

Comment (by thomaswm):

 Replying to [comment:28 jeremyfelt]:
 > Overall - I think it would be appropriate to avoid loading the entire
 WordPress 404 process for missing static files. My Apache rewrite memories
 have mostly been lost to Nginx rules. Any ideas on how that could be
 handled?

 Look at these directives in the current version of `.htaccess`:

 {{{
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]
 }}}

 They basically say: "If the user has requested an ''existing'' file or
 folder, stop the URL rewriting (and send the requested file or folder to
 the user)."

 So, if there's a file or folder that matches the path and filename in the
 request URI, the following rewrite rules will not be evaluated which means
 that in all following rewrite rules, we can assume that there's no file or
 folder that matches the request URI.

 After those directives that I cited above, we could add another rule which
 then handles the case that the user requested a file or subfolder of `wp-
 content` which ''does not exist''.

 {{{
 RewriteRule ^wp-content/(.+) - [R=404]
 }}}

 This would make Apache return an error 404 whenever the requested URL
 starts with `wp-content/` and no file or folder with matching name was
 found.

 Or, if you want to make a difference between non-existent files and non-
 existent, then we can go with these:

 {{{
 RewriteRule ^wp-content/(.+)/$ - [R=403]
 RewriteRule ^wp-content/(.+) - [R=404]
 }}}

 Here, the first rule checks that the request URI starts with `wp-content/`
 and ends with a trailing slash `/`. If that's the case, Apache returns an
 error 403, otherwise an error 404.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/20746#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list