【发布时间】:2015-04-15 12:42:30
【问题描述】:
我正在尝试在 CodeIgniter 上使用 .htaccess,但它不起作用。
我已经设置好了:
AllowOverride All
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
我在 Windows 上使用 XAMPP。
我的.htaccess:
RewriteEngine On
RewriteCond $1 !^(index\.php|images|scripts|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
我的 URL 仍然包含 index.php,如果我尝试手动删除它,它会返回 404 错误
另外我担心的是我的登录页面:每当我登录时,我的 URL 都会卡在检查页面上。
我想知道如何重写我的 URL 以更改为主页而不是停留在检查页面上。
public function check(){
$this->load->model('check');
$logcheck = $this->check->check($this->input->post('username'),$this->input->post('password'));
if($logcheck == "admin"){
$this->load->view('home');
}else{
$this->load->view('login');
}
}
【问题讨论】:
-
我通过将 htaccess 从应用程序文件夹转移到我的根文件夹来工作。想知道如果您仍然需要移动它,他们为什么要把它放在那里
-
每个文件夹都有自己的 htaccess 文件,可防止浏览特定(系统)文件夹,例如应用程序或系统。你应该把它原封不动地留在那里。对于根文件夹,您需要创建自己的 .htaccess 文件。
-
登录后当前获取的 URL 以及预期的 URL
-
@ShaifulIslam 登录后是:电话簿/检查/,我想要的是电话簿/家庭/。我该如何改变这个?
-
@Tpojka 我明白了,我会试一试,谢谢 :)
标签: php apache .htaccess codeigniter mod-rewrite