目录覆盖Wordpress

时间:2011-01-19 02:27:07

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

在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

任何人都知道我做错了什么?

1 个答案:

答案 0 :(得分:0)

想出来。 Wordpress没有在项目中添加尾部斜杠,因此它将我发送到/experiments,然后Apache想要将我发送回/experiments/,从而产生循环。

对网址进行了大量阅读(非常有趣/有趣),现在决定在我的所有网址上添加尾部斜杠。一切都很完美。

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