不带索引的 Codeigniter Url.php


Codeigniter Url without index.php

我想创建一个应用程序网址'http://example.com'。但是输入网址,它会显示"HTTP错误403.14 - 禁止"。当我在URL的最后一个插入"index.php"(如"http://example.com/index.php")时,登录页面正在浏览器中呈现我已经改变了

$config['base_url'] = 'http://example.com';
$config['index_page'] = '';

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

在配置文件.php文件中。然后,我将.htaccess文件与应用程序和系统文件夹一起放在codeigniter根文件夹中。然后在我编码的 .htaccess 文件中

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

我只想从 url 中删除"索引.php"。我正在使用 IIS 8.5 Web 服务器。

在 CI 中,您可以在登录成功时设置会话数据:

$this->session->set_userdata('username' $this->input->post('username'))

您可以在注销时取消设置

$this->session->sess_destroy();

并将数据库用于会话:https://www.codeigniter.com/user_guide/libraries/sessions.html