Wordpress 的问题ߣ请求现有文件时的 mod_rewrite 规则
请看一下我的 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
/lo/
的DirectoryIndex
是否指向/lo/index.php
?如果是这样,并且假设您对 Pekka 问题的回答是“是”,则问题可能源自第四个
RewriteRule
。对/lo/
的请求映射到/lo/index.php
,它匹配...并被重写为您的
index.php
站点根目录,即 WordPress 文件。我不确定这条规则的意义是什么(它确实阻止访问 WordPress.php
文件,但以一种超通用的方式),所以我不知道最好的是什么建议对其进行调节,但以下方法可行:Does
/lo/
'sDirectoryIndex
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...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: