要去掉 CodeIgniter(CI)中的 index.php,需要进行以下步骤:
sudo a2enmod rewrite
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
$config['index_page'] = 'index.php';
将其修改为:
$config['index_page'] = '';
RewriteRule ^(.*)$ /myapp/index.php/$1 [L]
现在,你应该能够在 CI 中访问没有 index.php 的 URL。例如,你可以通过以下 URL 访问默认控制器中的 index 方法:
http://example.com/controller/method
注意:如果你的服务器是 Nginx 而不是 Apache,你需要相应地修改服务器配置文件来实现相同的效果。
上一篇:php获取时间不对的解决办法
下一篇:php隐藏后缀名的方法是什么
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站