【问题标题】:Codeigniter Controller link is not working in IISCodeigniter 控制器链接在 IIS 中不起作用
【发布时间】:2020-04-10 00:33:05
【问题描述】:

我创建了一个网站并托管在 IIS 服务器中,但我无法访问我网站的内部链接。

例如:http://example.com/about 其中 'about' 是控制器。

这里 http://example.com 运行良好,但 http://example.com/about 返回 404 错误。

【问题讨论】:

  • 您是否通过htaccess 删除了index.php?试试http://example.com/index.php/about
  • 你需要查看你的 .htaccess 文件
  • 检查子文件夹的安全组权限,见stackoverflow.com/questions/14934006/…
  • 对于声明使用 .htaccess 的评论者:IIS 不使用 .htaccess,.htaccess 用于 Apache Web 服务器。
  • @OP 还会检查您的 IIS 错误日志,请参阅 stackoverflow.com/questions/6426375/… 以了解您的日志文件应该在哪里。日志文件的路径必须在 IIS 中配置。

标签: php codeigniter iis controller


【解决方案1】:

据我所知,如果你想在 IIS 中托管 Codeigniter,你需要添加一些特殊的 url 重写规则来让你的应用程序运行良好。

我建议你可以先安装 IIS 的 url rewrite 扩展。

那么我建议你可以尝试在 web.config 中添加以下规则。

  <system.webServer>

    <rewrite>

      <rules>

          <rule name="Index">

          <match url="^(.*)$" />

          <conditions>

            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

          </conditions>

                <action type="Rewrite" url="index.php/{R:1}" />

        </rule>

      </rules>

    </rewrite>

  </system.webServer>

【讨论】:

  • 我没有使用 web.config 文件,没有 web.config 主页正在加载。
猜你喜欢
  • 2013-04-30
  • 2019-06-28
  • 1970-01-01
  • 1970-01-01
  • 2023-03-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-11
相关资源
最近更新 更多