简体   繁体   English

找不到codeigniter site_url 404页面

[英]codeigniter site_url 404 page not found

I'm using CodeIgniter in localhost (MAMP) starting with the project example given with CodeIgniter itself. 我在localhost(MAMP)中使用CodeIgniter,从CodeIgniter本身给出的项目示例开始。 I want to load a view from welcome_message.php, so first of all in welcome Controller I've written 我想从welcome_message.php加载视图,因此首先在我编写的welcome Controller中

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

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

then I've create the new view with a simple text. 然后用简单的文本创建新视图。 In welcome_message.php I've put 在welcome_message.php中,我已经输入

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

(both the views are in views folder) (两个视图都在views文件夹中)

When I open welcome_message.php in my browser I see the link but when I click on it Test.php is not loaded. 当我在浏览器中打开welcome_message.php时,我看到了链接,但是当我单击它时,未加载Test.php。 I read only 我只读

404 Page Not Found The page you requested was not found. 404找不到页面未找到您请求的页面。

In other project that I've seen on the web this works without problems, I don't know how can I fix it. 在网上看到的其他项目中,该项目可以正常工作,但我不知道该如何解决。

I would recommend to check your .htaccess file. 我建议检查您的.htaccess文件。 Create a new .htaccess file in the root of Code Igniter with the following: 使用以下代码在Code Igniter的根目录中创建一个新的.htaccess文件:

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

Besides that your routing has to be done in 除此之外,您的路由必须在

application/config/routes.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM