wordpress mu 404 without end slash

2019-08-04 05:06发布

问题:

I've just setup a wordpress MU install and almost everything seems to be in working order. When i hit site.com/subsite i get a 404 on site.com but when i go to site.com/subsite/ (notice the trailing slash) everthing seems to work fine.

the generated wordpress mod_rewrite code is

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-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]
# END WordPress

any suggestions on how i should adjust this or any other settings to stop the 404s?

回答1:

I've hit this issue with respect to pages, but haven't used a multisite install with blogs differentiated by subpaths (only by different domains).

However, it may be solved in the same way:

Go to the Settings -> Permalink admin page and modify the permalink structure to eliminate the trailing slash. For example, if it has the default or one of the presets selected, just duplicate the string into the custom field, but without and trailing slash.

WP will always issue a redirect from one to the other (e.g. from http://example.com/ to http://example.com - or vice-versa if you do have trailing slashes in the permalink structure)

I don't know why it is issuing a 404 for your site.com instead of a 302 to site.com/ (perhaps redirection to the canonical URL is actually an option somewhere)

Hope that helps.