【发布时间】:2015-05-01 07:16:07
【问题描述】:
我正在使用codeigniter-3,并且我已将routes.php 中的默认控制器设置为
$route['default_controller'] = 'home';
我为这个项目设置了Virtual Host,我的.htaccess 看起来像这样
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule !^[A-Za-z0-9_/\-\.]*$ - [L,R=404]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
我的 config.php 是这样的
$config['index_page'] = '';
如果默认控制器设置为welcome,则可以正常工作
【问题讨论】:
-
检查你的控制器文件名是
home.php和控制器类是Home。我确定你复制了文件并忘记更改类名。 -
是否应该在允许字符的重写规则中也检查冒号?
-
你确定所有的控制器都像 Welcome.php 一样大写
-
是的,它们都是大写的
标签: codeigniter-3 php .htaccess codeigniter