[wp-trac] [WordPress Trac] #49069: Multisite: 404 template isn't used in network installs when a file extension is used in the URL
WordPress Trac
noreply at wordpress.org
Mon Dec 23 18:15:23 UTC 2019
#49069: Multisite: 404 template isn't used in network installs when a file
extension is used in the URL
--------------------------------------+------------------------------
Reporter: henry.wright | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: 2nd-opinion dev-feedback | Focuses: multisite
--------------------------------------+------------------------------
Changes (by pbiron):
* keywords: => 2nd-opinion dev-feedback
Comment:
@henrywright Unfortunately, as far as I know, the
[https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond
RewriteCond] syntax is not expressive enough to "improve the pattern
matching".
However, I'm not sure if this is what @apedog was suggesting in his
comment (and I'd never thought of this before), but since the
[https://httpd.apache.org/docs/2.4/mod/core.html#errordocument
ErrorDocument] directive is allowed in .htaccess, changing the multiste
mod_rewrite rules to the following seems to works:
== new multisite sub-directory rewrite rules
{{{
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# the following is the new rule.
# it forces WP to handle the request when apache detects a 404 as a result
of
# the "RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]" rule.
ErrorDocument 404 /index.php
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?fwp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
}}}
== new multisite sub-domain rewrite rules
{{{
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# the following is the new rule.
# it forces WP to handle the request when apache detects a 404 as a result
of
# the "RewriteRule ^(.*\.php)$ $1 [L]" rule.
ErrorDocument 404 /index.php
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
}}}
I've tried the above on a few local multisites and it seems to work. I
haven't tested it enough to know whether it will cause unintended
consequences. Would love to get some more feedback from others.
As I've never used nginx, I have no idea whether there is an equivalent
for it's rules (or IIS, for that matter).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49069#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list