WordPress mu 404没有结束斜杠

发布于 2024-09-25 16:37:41 字数 773 浏览 0 评论 0原文

我刚刚安装了 WordPress MU,几乎一切似乎都在正常工作。 当我访问 site.com/subsite 时,我在 site.com 上收到 404,但是当我访问 site.com/subsite/(注意末尾的斜杠)时,一切似乎都工作正常。

生成的 wordpress mod_rewrite 代码

# 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

对我应该如何调整此设置或任何其他设置以停止 404 有任何建议吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少女情怀诗 2024-10-02 16:37:41

我在页面方面遇到了这个问题,但没有使用通过子路径(仅通过不同域)区分博客的多站点安装。

不过也可以用同样的方法解决:

进入设置->永久链接管理页面并修改永久链接结构以消除尾部斜杠。例如,如果它选择了默认值或预设之一,只需将字符串复制到自定义字段中,但不带尾部斜杠。

WP 总是会发出从一个到另一个的重定向(例如从 http://example.com/http://example.com - 反之亦然,如果您在永久链接结构中确实有尾部斜杠)

我不知道为什么正在为您的 site.com 发出 404,而不是向 site.com/ 发出 302
(也许重定向到规范 URL 实际上是某个地方的一个选项)

希望有所帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文