【问题标题】:I keep getting ERROR 404 in CodeIgniter我在 CodeIgniter 中不断收到 ERROR 404
【发布时间】:2017-07-10 22:37:52
【问题描述】:

我刚刚开始使用 CodeIgniter,我正在研究这个示例 https://www.codeigniter.com/user_guide/tutorial/static_pages.html

这是我的网址:

localhost/CodeIgniter-3.1.5/CodeIgniter -3.1.5/index.php/application/controllers/pages/view/about

我不认为它有什么问题,但是当我尝试访问它时,我不断收到错误 404。

【问题讨论】:

  • 您是否命名了页面控制器,其中文件名和类只有第一个字母大写。 Pages.phpclass Pages extends CI_Controller {} 也可能是您需要在主目录中使用 htaccess。
  • 错误 404 是页面未找到错误。你的路径是错误的。 localhost 会把你送到某个地方吗?
  • 是的,我已经将控制器命名为 Pages.php 并且我有一个 htaccess 文件
  • @Eric 它应该带我到关于页面
  • 你的网址看起来不对

标签: codeigniter codeigniter-3


【解决方案1】:

你的网址是错误的。

如果你有正确的 .htaccess,你的 url 应该是这样的:

localhost/CodeIgniter-3.1.5/CodeIgniter-3.1.5/Pages/view/about

并且没有正确的 .htaccess 文件:

localhost/CodeIgniter-3.1.5/CodeIgniter-3.1.5/index.php/Pages/view/about

这是一个合适的 .htaccess 文件:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

【讨论】:

    猜你喜欢
    • 2010-10-17
    • 2015-04-12
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-06
    • 1970-01-01
    相关资源
    最近更新 更多