【问题标题】:No .htaccess on root directory but redirects infinitely根目录上没有 .htaccess,但无限重定向
【发布时间】:2016-11-08 23:35:46
【问题描述】:

我有一个只有几个 .html 文件的网站。 index.html 是主页。然后我使用 CodeIgniter 3 扩展了这个网站。 旧网站在http://example.com/ 上工作,新网站在http://example.com/ci 上工作 一切都很好,直到我尝试施展魔法。我决定将新版本留在ci 目录中并使用 .htaccess 添加重定向规则:

#.htaccess file on the root (/) directory
Redirect / /ci

进入死循环,页面打不开。然后我删除了该行,但它仍然尝试重定向到/ciciciciciciciciciccici...

我删除了根目录下的 .htaccess。

位于/ci 目录中的另一个 .htaccess 具有以下几行:

RewriteEngine on
RewriteBase /ci
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

如果我输入example.com/example.com/ci,两种情况都会发生无限重定向。

有什么我忘记更改的吗?这可能是因为服务器反应迟钝吗?

编辑

为了测试,我在/ci/目录下的.htaccess中改了一行,

RewriteEngine on
#RewriteBase /ci
RewriteBase /hh # which does not exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

它仍然尝试重定向到/ci

编辑 2

如果我输入完整的网址,它会打开页面。例如:

example.com/ci/contact ---> opens
example.com/index.html ---> opens

example.com/           ---> error
example.com/ci         ---> error

example.com/ci/        ---> OPENS! Strange!

【问题讨论】:

  • 您清除缓存了吗?大多数浏览器缓存重定向规则。
  • @Devon 我做到了。我尝试了不同的浏览器。

标签: php apache .htaccess codeigniter redirect


【解决方案1】:

这都是关于缓存的,但在服务器端。它现在正在工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-12
    • 2012-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-21
    • 2010-12-09
    相关资源
    最近更新 更多