带有 quercus 的 codeigniter 显示 404 错误

Posted

技术标签:

【中文标题】带有 quercus 的 codeigniter 显示 404 错误【英文标题】:codeigniter with quercus shows 404 error 【发布时间】:2016-08-15 21:27:53 【问题描述】:

我正在尝试使用 quercus 在 tomcat 上运行 codeigniter。

我在 webapps/ROOT 中安装了 quercus,然后在 webapps/ROOT/appname 中安装了 codeigniter。

我可以在 webapps/ROOT/appname 中访问 index.php,但是如果我尝试访问 ROOT/appname/index.php/login/login,就会出现 404 错误。我什至无法访问 ROOT/appname/welcome。

如何解决这个 404 错误?

我正在使用 codeigniter 2.x。


我使用 urlrewriterfilter 来替换 htaccess。但它似乎不起作用。 以下是我的 urlrewrite.xml。

<urlrewrite>
  <rule>
    <name>Generic Pretty URLs Pass-through</name>
    <condition type="request-uri" operator="notequal">^/(robots.txt|osd.xml|flex2gateway|cfide|cfformgateway|railo-context|admin-context|files|images|jrunscripts|javascripts|miscellaneous|stylesheets)</condition>
    <condition type="request-uri" operator="notequal">\.(bmp|gif|jpe?g|png|css|js|txt|xls|ico|swf|woff|ttf|otf)$</condition>

        <condition type="request-filename" operator="notdir"/>
        <condition type="request-filename" operator="notfile"/>

        <from>(.*)</from>
        <to type="passthrough" last="true">index.php/$1</to>
</rule>
</urlrewrite>

【问题讨论】:

Codeigniter 的“漂亮 URL”路由需要一个 .htaccess 文件,其中包含 Apache HTTPD 中的一些重写规则。 Quercus 不支持这个 .htaccess 文件。你需要这样的东西:***.com/questions/5920870/… 谢谢塞尔吉乌。不幸的是,参考文献并没有帮助。我还发现了 urlrewriterfilter,但找不到将 codeigniter 的 htaccess 更改为 urlrewrite.xml 的示例 Codeigniter 的 htaccess 是所有实现前端控制器模式的框架都使用的。您应该可以使用将公用文件夹中现有文件以外的任何内容重定向到 index.php 的任何 urlrewrite.XML。 好像不行。我在上面附上了我的 urlrewrite.xml。 【参考方案1】:

我找到了答案。我不太确定它是否与 URL 路由有关。但解决方案是把'?在 index.php 之后。长话短说,我只是喜欢以下内容: /appname/index.php?/login/login

然后就可以了!

【讨论】:

以上是关于带有 quercus 的 codeigniter 显示 404 错误的主要内容,如果未能解决你的问题,请参考以下文章

带有 Codeigniter 会话到期时间的帮助

codeigniter 中的友好 url,带有 url 中的变量

带有 CodeIgniter 的 PayPal IPN

带有 Codeigniter 的 Croppic jQuery 插件

Codeigniter 4 不适用于带有 PHP 8.0 的 xampp

带有获取参数的codeigniter分页url