Codeigniter - 使用.htaccess隐藏index.php

时间:2013-03-09 05:32:27

标签: .htaccess codeigniter

我的网站:

  

http://ibnight.com

尝试访问我网站上的活动时:

  

http://ibnight.com/1

我收到一个未找到的错误:

  

在此服务器上找不到请求的URL /。

仅当我使用url中的index.php访问它时才有效,例如:

  

http://ibnight.com/index.php/1

我的控制器类似于:

class Events extends CI_Controller {

    public function __construct()
    {}

    public function index()
    {}

    public function event()
    {}

} 

我的路线:

$route['default_controller'] = 'events';
$route['(:num)'] = $route['default_controller'] . '/event/$1'; 

我的配置:

$config['index_page'] = '';

我的.htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 

2 个答案:

答案 0 :(得分:0)

试试这个:

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] 

答案 1 :(得分:0)

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
相关问题