codeigniter的.htaccess和URL重定向问题 [英] Codeigniter Htaccess and URL Redirect issues
问题描述
我想使用的.htaccess
在codeIgniter,但它不能正常工作。
我已经设置:
的AllowOverride所有
$配置['index_page'] ='';
$配置['uri_protocol'] ='REQUEST_URI';
我使用的XAMPP在Windows上。
我的的.htaccess
:
RewriteEngine叙述上
的RewriteCond $ l ^(指数\ .PHP |图片|脚本| CSS |机器人\ .TXT)!
重写规则^(。*)$ /index.php/$1 [L]
我的网址仍然包含的index.php
,如果我尝试手动删除它,它会返回一个404错误
还有我的其他值得关注的是我的登录页面:每当我登录,我的网址粘贴在检查页
我想知道我怎么重写我的网址更改停留在检查页面的主页吧。
公共功能检查(){
$这个 - >负载>模型('检查');
$ Logcheck的= $this->check->check($this->input->post('username'),$this->input->post('password'));
如果($ Logcheck的==管理员){
$这个 - >负载>查看(家);
}其他{
$这个 - >负载>查看('登录');
}
}
这个简单的.htaccess将删除你的index.php
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php / $ 1 [L]
更改您的检查功能像这样
公共功能检查(){
$这个 - >负载>模型('检查');
$ Logcheck的= $this->check->check($this->input->post('username'),$this->input->post('password'));
如果($ Logcheck的==管理员){
//可能是你需要设置的登录凭证进入会议
重定向(电话簿/家居/');
// $这个 - >负载>查看(家);
}其他{
$这个 - >负载>查看('登录');
}
}
和您的家庭功能会是这样
公共职能的家(){
//记住,你需要检查的会话登录验证
$这个 - >负载>查看(家);
}
使用重定向
功能还记得你有网址
帮手加载。
可能是这个帮助你
I am trying to use .htaccess
on CodeIgniter, but it is not working.
I have already set:
AllowOverride All
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
I am using XAMPP on Windows.
My .htaccess
:
RewriteEngine On
RewriteCond $1 !^(index\.php|images|scripts|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
My URL still contains index.php
and, if I try to remove it manually, it returns a 404 error
Also my other concern is my login page: whenever I login, my URL is stuck on the check page.
I was wondering how do I rewrite my URL to change to home page instead of staying on the check page.
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');
}
}
This simple .htaccess will remove your index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Change your check function like this
public function check(){
$this->load->model('check');
$logcheck = $this->check->check($this->input->post('username'),$this->input->post('password'));
if($logcheck == "admin"){
//may be you need to set login credential into session
redirect('Phonebook/home/');
//$this->load->view('home');
}else{
$this->load->view('login');
}
}
and your home function will be like this
public function home(){
//remember you need to check login validation from session
$this->load->view('home');
}
to use redirect
function remember you have url
helper loaded.
May be this help you
这篇关于codeigniter的.htaccess和URL重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!