Wordpress 的问题ߣ请求现有文件时的 mod_rewrite 规则

发布于 2024-09-13 08:41:04 字数 620 浏览 3 评论 0原文

请看一下我的 .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

对于 Wordpress,它工作正常。

但我有一个问题:我有一个名为lo的目录,用于链接交换,与Wordpress博客无关。 现在,我无法访问我的 lo 目录,它会将我重定向到 WordPress 帖子。 为什么?

please take a look at my .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

For Wordpress it works fine.

But I have a problem: I have a directory called lo, used for links exchange, has nothing to do with the Wordpress blog.
Now, I can't access my lo directory, it redirects me to a wordpress post.
Why?

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

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

发布评论

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

评论(1

扛起拖把扫天下 2024-09-20 08:41:04

/lo/DirectoryIndex 是否指向 /lo/index.php

如果是这样,并且假设您对 Pekka 问题的回答是“是”,则问题可能源自第四个 RewriteRule。对 /lo/ 的请求映射到 /lo/index.php,它匹配

RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]

...并被重写为您的 index.php站点根目录,即 WordPress 文件。我不确定这条规则的意义是什么(它确实阻止访问 WordPress .php 文件,但以一种超通用的方式),所以我不知道最好的是什么建议对其进行调节,但以下方法可行:

RewriteCond %{REQUEST_URI} !^/lo
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]

Does /lo/'s DirectoryIndex point to /lo/index.php?

If so, and assuming your answer to Pekka's question is "Yes", the problem likely originates from the fourth RewriteRule. A request to /lo/ maps to /lo/index.php, which matches

RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]

...and gets rewritten to index.php in your site root, which is the WordPress file. I'm not sure what the point of this rule is (it does block access to WordPress .php files, but in kind of a super-general way), so I don't know what the best recommendation is for conditioning it, but the following would work:

RewriteCond %{REQUEST_URI} !^/lo
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文