【问题标题】:Directory Overriding on WordpressWordpress 上的目录覆盖
【发布时间】:2011-01-20 12:07:15
【问题描述】:

在 WordPress 中,我有一个名为 Experiments 的页面,其中包含 experiments。该页面应该可以通过http://site.com/experiments 访问。

问题是,我还想在我的服务器上有一个具有该名称的文件夹,以便http://site.com/experiments/thing/ 加载该文件夹的index.html 文件(如果有的话)。

我以为我找到了完美的重写结构(来自this blog post):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
#   RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}/index.htm !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . /index.php [L]
</IfModule>

# BEGIN WordPress
# END WordPress

看起来它使用 WordPress 重写目录,除非该目录有 index.html 或 index.php 文件,在这种情况下它会忽略 WordPress 加载它。它非常适用于子目录,但http://site.com/experiments/ 试图永远来回重定向到http://site.com/experiments

有人知道我做错了什么吗?

【问题讨论】:

    标签: php apache wordpress mod-rewrite url-rewriting


    【解决方案1】:

    想通了。 Wordpress 没有在项目中添加斜杠,所以它把我送到/experiments,然后 Apache 想把我送回/experiments/,导致循环。

    对 URL 进行了大量阅读(这非常有趣/有趣),现在决定在我的所有 URL 中添加尾部斜杠。一切都运行良好。

    编辑:一个有趣的旁注是,Wordpress 会根据您的自定义永久链接结构中是否存在斜杠来决定是否在任何地方使用斜杠(即/%postname%/)。浪费了大量时间搜索我设置的位置,它一直就在那里。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-23
      • 1970-01-01
      • 2016-10-31
      • 2018-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-09
      相关资源
      最近更新 更多