当用户键入索引时,我需要在URL中显示404页面.php为:
http://localhost:8080/site_name/index.php/home
我在路线中添加了这个.php $route['index.php/(:any)'] = 'custom404';
它没有帮助;当用户键入http://localhost:8080/site_name/index.php/home
主页显示而不是404时找不到。
知道如何在URL中当用户键入索引时显示404页面.php?
我的访问:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /site_name/index.php/$1 [L]
您可以一起从网址中删除索引.php。 默认情况下,CodeIgniter 处于打开状态,但您可以轻松将其删除,只需按照其用户指南中的指南进行操作即可:http://codeigniter.com/user_guide/general/urls.html
编辑:还应该知道,URL中的索引.php不是控制器的一部分,它只是CodeIgniter放在那里的东西,因此您无法使用路由将其删除。
将
默认控制器设置为 custom404
$route['default_controller'] = "custom404";
或者你可以试试这个:
$route['index.php/^(.+)$'] = "custom404";