我对CodeIgniter3有问题:找不到404页
文件:application / controllers / Welcome.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->view('Welcome_Page');
}
public function tutorial()
{
$this->load->view('Tutorial_Page');
}
public function manual()
{
$this->load->view('Manual_Page');
}
public function forum()
{
$this->load->view('Forum_Page');
}
public function register()
{
$this->load->view('Register_Page');
}
public function login()
{
$this->load->view('Login_Page');
}
}
文件:application / config / autoload / php
$autoload['helper'] = array('url');
文件:application / config / routes.php
$route['default_controller'] = 'welcome';
$route['translate_uri_dashes'] = FALSE;
文件:application / config / config.php
$config['base_url'] = 'http://subdomain.domain.tld';
$config['index_page'] = '';
档案:.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
页面加载Welcome_Page,但不加载其他页面。
404 Page Not Found
The page you requested was not found.
在文件夹视图中,存在以下页面:Forum_Page.php,Login_Page.php,Manual_Page.php,Register_Page.php,Tutorial_Page.php和Welcome_Page.php
非常感谢您的理解!
啊,我明白了。您的问题在于路由。您的目的是要访问以下网页
http://sub.domain.tld/welcome/tutorial
http://sub.domain.tld/welcome/manual
...
但是您创建了视图HTML以获取
http://sub.domain.tld/tutorial
http://sub.domain.tld/manual
...
在APPPATH.'config/routes.php'
文件中,在保留的路由下,您必须通过以下方式重新路由呼叫:
$config[(:any)] = 'welcome/$1'
这里有两件事需要注意:
(:any)
将用于$1
,(:any)
参数的路由必须在文件末尾,因为
路线将按照定义的顺序运行。较高的路线将始终优先于较低的路线。
这里更多。检查整个页面以及文档中的其他页面。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句