CodeIgniter:通过输入视图的url来显示视图


CodeIgniter: show a view by typing its url

这里的新手:抱歉,如果问题太简单,一直在看教程,但我似乎不正确。

我有

$route['default_controller'] = "mainpage";

在routes.php中工作正常,现在我只想查看视图文件夹中的一个php页面,输入它的url:

http://myserver/folder/thepageIwantToSee

我得到404 Not Found错误。我必须使用控制器吗?我只是想在链接之前先看看,有什么办法吗?

非常感谢!

class yourcontroller extends CI_Controller {
     function pageiwanttosee()
     {
         code
         code
         $this->load->view('the_view_page', $data);
     }
 }

是的,你可以写一个控制器来显示指定的视图。

http://myserver/showfile/folder/thepageIwantToSee,其中showfile为控制器。

不要忘记在生产站点设置一些安全检查或禁用此功能。