【问题标题】:codeigniter site_url 404 page not found找不到codeigniter site_url 404页面
【发布时间】:2012-11-02 13:45:09
【问题描述】:

我在 localhost (MAMP) 中使用 CodeIgniter,从 CodeIgniter 本身给出的项目示例开始。我想从welcome_message.php 加载一个视图,所以首先在我写的欢迎控制器中

public function index()
{
    $this->load->helper('url');

    $this->load->view('welcome_message');
}

然后我用一个简单的文本创建了新视图。在welcome_message.php 我放了

<a href="<?php echo site_url('test');?>">Test</a>

(两个视图都在views文件夹中)

当我在浏览器中打开welcome_message.php 时,我看到了链接,但是当我点击它时,Test.php 没有加载。我只读了

404 页面未找到 未找到您请求的页面。

在我在网上看到的其他项目中,这没有问题,我不知道如何修复它。

【问题讨论】:

  • 您需要创建一个名为Test 的控制器,其函数为index,并在其中加载测试视图。
  • 你说得对,谢谢。如果您将其写为答案,我会将其设置为正确的答案。

标签: php codeigniter url views


【解决方案1】:

我建议检查您的 .htaccess 文件。在 Code Igniter 的根目录中创建一个新的 .htaccess 文件,内容如下:

RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]

除了你的路由必须在

application/config/routes.php

【讨论】:

    猜你喜欢
    • 2020-07-14
    • 2019-12-02
    • 1970-01-01
    • 2016-11-14
    • 1970-01-01
    • 2013-02-28
    • 2016-12-06
    • 1970-01-01
    相关资源
    最近更新 更多