我正在开发一个基于 Ubuntu & Apache2 & CodeIgniter 的应用程序
我有一个Site这样命名的控制器
class Site extends CI_Controller {
public function view($page = 'home')
{
$this->load->view('site/'.$page, $data);
}
}
在application/views/site我有home.php&about.php
localhost/index.php/about效果很好
,但localhost/about得到
Not Found,The requested URL /about was not found on this server.
我已经
- 确保
mod_rewrite打开并AllowOverride All在 apache2 配置文件中。 $config['index_page'] = '';在application/config/config.php
我也设置了路线
$route['default_controller'] = "site/view";
$route['404_override'] = '';
$route['(:any)'] = "site/view/$1";
这是我的.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<Files "index.php">
AcceptPathInfo On
</Files>