[英]codeigniter redirect function puts ? between base_url and controller/function
I made a login script to access another controller so other people can't see that. 我制作了一个登录脚本来访问另一个控制器,以便其他人看不到。
now I have a redirect function in my controller that redirects to another controller. 现在我的控制器中有一个重定向功能,可以重定向到另一个控制器。
now when I redirect it works fine, but it puts a ? 现在当我重定向它工作正常,但它放一个? between my base_url and the controller like this:
在我的base_url和控制器之间,如下所示:
http://kees.een-site-bouwen.nl/?/member/index http://kees.een-site-bouwen.nl/?/member/index
How do I solve that? 我该如何解决?
My home controller function: 我的家庭控制器功能:
public function process(){
// Load the model
$this->load->model('login_model');
// Validate the user can login
$result = $this->login_model->validate();
// Now we verify the result
if(! $result){
// If user did not validate, then show them login page again
$msg = '<font color=red>Invalid username and/or password.</font><br />';
$this->index($msg);
}else{
// If user did validate,
// Send them to members area
redirect('/member/index');
}
}
Does it have to do with my .htaccess file? 它与我的.htaccess文件有关吗?
It looks like this: 看起来像这样:
<IfModule mod_rewrite.c>
RewriteEngine On
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^LoginTut.*
RewriteRule ^(.*)$ index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
使用redirect('member/index')
插入的redirect('/member/index')
;
Change your htaccess to: 将您的htaccess更改为:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{REQUEST_URI} ^LoginTut.*
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
so that url are resolved to index.php/controller
instead of index.php?/controller
以便将网址解析为
index.php/controller
而不是index.php?/controller
I solved it by disabling query_strings like so: 我通过禁用query_strings来解决它,如下所示:
From: 从:
$config['enable_query_strings'] = TRUE;
To: 至:
$config['enable_query_strings'] = FALSE;
In my Config.php file. 在我的Config.php文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.