2017-04-26 128 views
2

調用此函數將我重定向到登錄網頁會導致'404錯誤:找不到您請求的頁面'。我遵循了與其他應用程序相同的步驟,並且它運行良好。有任何想法嗎?關於使用Codeigniter的註銷功能(Ion Auth)的錯誤404

鏈接

<li> 
          <a href="<?= base_url('auth/logout') ?>">Salir</a> 
         </li> 

離子驗證功能

// log the user out 
public function logout() { 
    $this->data['title'] = "Logout"; 

    // log the user out 
    $logout = $this->ion_auth->logout(); 

    // redirect them to the login page 
    $this->session->set_flashdata('message', $this->ion_auth->messages()); 
    redirect('auth/login', 'refresh'); 
} 

BASE_URL

$config['base_url'] = 'http://localhost/herba/'; 

回答

0

更改此

public function logout() { 
    $this->data['title'] = "Logout"; 

    // log the user out 
    $logout = $this->ion_auth->logout(); 

    // redirect them to the login page 
    $this->session->set_flashdata('message', $this->ion_auth->messages()); 
    redirect(base_url('auth/login'), 'refresh'); 
} 

請確保 http://localhost/herba/auth/login存在

index.php

http://localhost/herba/index.php/auth/login

+0

謝謝!它與'http://localhost/herba/index.php/auth/login'一起工作,但我不明白,它應該與'http:// localhost/herba/auth/login'一起作爲我的老項目。這是爲什麼發生? – Jose

+0

請檢查您的'.htaccess'文件。我認爲問題在那裏。 –

+0

問題在哪裏? !'RewriteEngine敘述在 的RewriteCond%{} REQUEST_FILENAME -f 的RewriteCond%{} REQUEST_FILENAME -d 1 的RewriteCond $ ^(指數\ .PHP |資產)!(。*) 重寫規則^ $ ./index.php?$1 [ L]' – Jose

0

還要檢查你是否已經啓用並allow_override mod_rewrite的這個項目在Apache設置?

+0

我使用xampp,我做了以下操作:http://www.leonardaustin.com/blog/technical/enable-mod_rewrite-in-xampp/但它不起作用 – Jose