【问题标题】:htaccess DirectoryIndex breaks access to Wordpress?htaccess DirectoryIndex 中断对 Wordpress 的访问?
【发布时间】:2014-02-05 11:00:14
【问题描述】:

我的目录 /blog 中有一个 wordpress 安装

我最近将此行添加到我的 .htaccess 中

DirectoryIndex /dgroup/index.php

现在我无法再访问博客主页,我不明白为什么。我什至尝试手动添加

 RewriteRule ^blog/$ blog/index.php

没有结果。

值得注意的是,我可以访问博客中的单个帖子,只是主页已损坏。

有什么想法吗?

提前致谢。

更多详情:

我无法再访问博客主页是指我收到错误 404。

我想要实现的只是将 dgroup/index.php 作为默认页面

【问题讨论】:

  • "现在我不能再访问博客主页" --- 这是什么意思?
  • 你想达到什么目的?

标签: php wordpress .htaccess


【解决方案1】:

dgroup/index.php should be the default page

删除您的DirectoryIndex 行并将此规则作为第一条规则放在您的DocumentRoot/.htaccess 中,以便在访问您的域的主页时打开/dgroup/index.php

RewriteRule ^/?$ /dgroup/index.php [L]

【讨论】:

  • 这很好用,非常感谢。只是好奇?为什么是 [L] 标志?它似乎在有和没有的情况下都有效。我虽然应该告诉它这是最后一条指令,但似乎我错了!
  • L 表示Last,这只是停止当前的重写循环注入规则以进行进一步处理。在这种情况下,您可能看不到差异,但下面有一些规则,然后L 可能会影响。
【解决方案2】:

您实际上是在告诉 apache“如果在目录中找不到资源,则提供 /dgroup/index.php”。您的规则将适用于任何目录。

因此,当您浏览到 /blog/post/something 时,这些目录不存在,因此 apache 会显示“好的,好吧,这里什么都不存在,所以让我们提供 /dgroup/index.php

我对你想要达到的目标有点困惑。如果您只想在有人访问 /dgroup 时提供 /dgroup/index.php ,请使用以下内容:

<Directory /dgroup>
    DirectoryIndex index.php
</Directory>

【讨论】:

  • dgroup(index.php 应该是默认页面,所以当有人去 domainname.com 时应该登陆那里。
  • 其实我可以访问/blog/post/something,顺便说一句。唯一的问题是博客主页
猜你喜欢
  • 2023-03-03
  • 2023-03-22
  • 1970-01-01
  • 1970-01-01
  • 2015-12-03
  • 1970-01-01
  • 2015-12-24
  • 2017-01-07
  • 2018-02-07
相关资源
最近更新 更多