Opened 5 years ago
Last modified 5 years ago
#52969 new defect (bug)
Permalink for /wp-includes falls back to blog post
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 5.6.1 |
| Component: | Rewrite Rules | Keywords: | |
| Focuses: | Cc: |
Description
After setting up WordPress, and enabling pretty looking permalinks, I found something odd happening.
The Apache rewrite rules have been also set up in the VHost config:
ServerName example.com
DocumentRoot /usr/share/wordpress
Alias /wp-content /var/www/example.com/wp-content
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^index\.php$ - [L]
RewriteCond /usr/share/wordpress%{REQUEST_URI} !-f
RewriteCond /usr/share/wordpress%{REQUEST_URI} !-d
RewriteCond /var/www/example.com%{REQUEST_URI} !-f
RewriteCond /var/www/example.com%{REQUEST_URI} !-d
RewriteRule . /index.php [L]
# Directory permissions omitted
Note: I have the (shared) code in /usr/share/wordpress and the actual site-specific content in /var/www/<domain-name> so I can host several sites with the same WP installation.
So, everything seems fine and dandy, until Chrome tries to load some .js.map files, which will raise a warning in the browser console:
DevTools failed to load SourceMap: Could not parse content for https://example.com/wp-includes/js/underscore.min.js.map: Unexpected token < in JSON at position 0
Having a look into the issue, I found, that most of the non-existent files will correctly return a 404 (as before the permalinks), however anything below /wp-includes/js/ will fall back to my first blog post. (So https://7c00.io/wp-includes/js/foo/ will also show my "hello-world" test post)
As due the rewrite rules everything is essentially handled by PHP, I suspect this is an issue with the WP permalinks business logic.
Checked another few URLs, and the issue seems to be present for other URLs too, for example:
example.com/wp-content/plugins/foo/example.com/wp-conetnt/themes/foo/example.com/wp-admin/foo/