CodeIgniter:将index.php保留在url中,并隐藏其余部分

时间:2018-10-11 08:39:35

标签: codeigniter

祝你好运...

问题: 如何将index.php保留在URL中并隐藏其他所有内容,以便每个页面的URL看起来都像(www.base_url.com/index.php)?

详细信息: 我已经搜索过,但是我只知道如何删除index.php,我想我是唯一想要保留它的人...大声笑

我使用Codeigniter 3来开发基于Web的应用程序人力资源管理,因此我不需要SEO网址,因为该应用程序仅由内部员工访问。我想使网址整洁,仅对每个页面显示base_url和index.php。请告诉我如何配置codeigniter,就像我需要的...谢谢

1 个答案:

答案 0 :(得分:0)

像这样使用.htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On

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

与index.php相比,它看起来更干净。该网址将是这样的www.your_baseurl.com/users

并编辑您的config.php文件以使用URI,如下所示:

$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

您可以这样使用您的路线:

$route['users'] = 'home/users';