2013-03-22 85 views
0

我做了一個登錄腳本來訪問另一個控制器,以便其他人不能看到它。codeigniter重定向函數放?在base_url和控制器/功能之間

現在我在我的控制器重定向到另一個控制器的重定向功能。

現在,當我重定向它工作正常,但它把一個?我BASE_URL像這樣的控制器之間:

http://kees.een-site-bouwen.nl/?/member/index

我該怎麼解決呢?

我家的控制器功能:

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'); 
    }   
} 

是否與我的.htaccess文件呢?

它看起來像這樣:

<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> 

回答

0

我通過禁用QUERY_STRINGS像這樣解決了這個問題:

來源:

$config['enable_query_strings'] = TRUE; 

收件人:

$config['enable_query_strings'] = FALSE; 

在我的Config.php文件中。

0

使用redirect('member/index') insted的的redirect('/member/index');

+0

那。顯然不工作。 – 2013-03-22 11:49:46

0

你的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> 

使URL決心的index.php/controller代替index.php?/controller

+1

你介意更細節而不是粗魯嗎? – 2013-03-22 13:18:12

相關問題