【发布时间】:2016-04-21 14:56:25
【问题描述】:
我想删除 index.php 以直接访问我的控制器。但是,我不能直接去我的控制器。我必须使用 index.php。例如:我想去 http://example.com/my_controller/method 而不是 http://example.com/index.php/my_controller/method
顺便说一句,我使用的是我的测试服务器,而不是像 XAMPP 这样的本地服务器。我在我的服务器中启用了 apache mod rewrite。
我尝试了很多 htaccess 规则,条件,但我无法工作。请帮帮我!
这是我的 .htaccess 文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
我的 config.php:
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
我怎样才能直接去?
【问题讨论】:
-
首先你使用的是什么版本的codeigniter以及什么localhost xampp、wamp等
-
我使用我的服务器来测试它。
-
如果您使用 wamp,请确保您已启用 apache mod rewrite。并使您的 htaccess 位于应用程序文件夹之外的主目录中。
-
@wolfgang1983 不,我不使用它,因为我使用的是我的测试服务器,而不是本地服务器。另外,我在我的服务器中启用了 apache mod rewrite,并尝试了主目录。
标签: php .htaccess codeigniter config