【问题标题】:Codeigniter - hide index.php with .htaccessCodeigniter - 使用 .htaccess 隐藏 index.php
【发布时间】:2013-03-09 14:23:19
【问题描述】:

我的网站:

http://ibnight.com

当尝试通过以下方式访问我网站中的活动时:

http://ibnight.com/1

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

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

仅当我使用 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] 

【问题讨论】:

标签: .htaccess codeigniter


【解决方案1】:

试试这个:

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

【讨论】:

    【解决方案2】:
    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    【讨论】:

      猜你喜欢
      • 2015-12-19
      • 1970-01-01
      • 2013-10-21
      • 2011-02-15
      • 1970-01-01
      • 2019-04-06
      • 1970-01-01
      • 2012-11-09
      • 1970-01-01
      相关资源
      最近更新 更多