【问题标题】:Code igniter 404 page not found errorCodeigniter 404 页面未找到错误
【发布时间】:2018-07-20 22:15:35
【问题描述】:

我在代码点火器上开发了一个 Web 应用程序。这是我第一次使用 code-igniter 在我的本地主机上开发 Web 应用程序后,它工作正常。但是当我在服务器中托管该站点时,主索引页面正在打开,但子页面显示"404 page not found error"。你能指导我吗?这是我的 htacess 文件

RewriteBase /

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/system.*

RewriteRule ^(.*) index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.+) index.php?/$1 [L]`

在我的routes.php 中,我添加了以下行

$route['about'] = 'mycontroller/about';

【问题讨论】:

  • 你在config.php$config['index_page'] = ''; 有什么?它应该在第 34 行附近。
  • 看看这个stackoverflow.com/questions/28801605/… 你会看到一些 htaccess 试试看。
  • 我替换了 $config['index_page'] = 'index.php'; $config['index_page'] = ' ';在 config.php 中
  • 然后发生了什么。您可能还需要检查路由是否与控制器和重定向等匹配。
  • 是的,我查过了!我提到了这个链接stackoverflow.com/questions/7615284/…,但我没有找到任何解决方案。他们提供的链接没有打开

标签: codeigniter


【解决方案1】:

您是否尝试设置配置?

$config['base_url'] = "https://www.yoursite.com/";

sajjad's blog 有一个很好的教程

【讨论】:

  • 仍然卡住.. ? your-domain.com/index.php/your-controller 可访问
  • 主页和一些页面使用 index.php 打开,当我在 URL 中使用 index.php 时,一些页面显示空白页
  • 我不知道,为什么会这样,你能给我网址吗
  • stackoverflow.com/questions/7615284/…我的错误与此类似
【解决方案2】:

将以下代码复制到您的 .htaccess 文件中:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L]

【讨论】:

    【解决方案3】:

    我的代码所有类名都以大写字母开头,但是很少有帖子提到更改文件名以匹配类名。然而,这并没有帮助。最后,以下帮助:

    创建一个文件 .htaccess 并在其中添加以下代码行:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|public|\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?$1
    

    它应该工作

    【讨论】:

      猜你喜欢
      • 2015-03-30
      • 2017-03-09
      • 1970-01-01
      • 2016-12-06
      • 2015-07-28
      • 1970-01-01
      • 1970-01-01
      • 2015-10-07
      • 2015-05-19
      相关资源
      最近更新 更多