2016-03-04 107 views
1

我有如何從文件夾調用codeigniter中的控制器?

  • 前端網站:WordPress的
  • 後端:笨

笨實例保存在名爲後端文件夾。

設置後端測試環境爲。

  • 文件夾名稱:團隊
  • 笨是安裝在: ABC文件夾

那麼路徑將是如下:

publichtml/team/abc

現在嘗試登錄有一個404找不到錯誤

任何一個可以幫助我什麼在腳本去錯:

POST https://example.com/team/abc/index.php/login/authenticateUserWeb

<script> 
function sendData() { 
    var username = $("#username").val(); 
    var userpass = $("#userpass").val(); 

    $.post('https://example.com/team/abc/index.php/login/authenticateUserWeb',{ 'username': username, 'userpass': userpass }, function(data) { 

    alert(data); 
    if(data == 'success'){ 
     window.location = "https://example.com/team/abc/index.php/companyadmin/folders"; 

    }else if(data == 'successuser'){ 
     window.location = "https://example.com/team/abc/index.php/companyuser"; 
    }else if(data == 'expired'){ 
     window.location = 'https://example.com/team/abc/index.php/companyadmin/selectPacakge';  

    }else{ 
      $("#user").html(data); 
      //alert(data); 
     } 

}); 

    } 

現在,當我試圖在控制檯日誌中發現以下錯誤簽名

301 Moved Permanently

jquery-1.10.2.js (line 6) GET https://example.com/team/abc/login/authenticateUserWeb

404 Not Found

https://example.com/team/abc/login/authenticateUserWeb

NetworkError: 404 Not Found

+1

不知道,但我注意到,index.php文件已經從https://example.com/team刪除/abc/index.php/login/authenticateUserWeb和url是像GET一樣的變化https://example.com/team/abc/login/authenticateUserWeb –

+1

這裏是我的配置文件:$ config ['base_url'] =「https:/ /example.com/team/abc/「; $ config ['index_page'] ='index.php'; $ config ['allow_get_array'] \t \t = TRUE; $ config ['enable_query_strings'] = FALSE; $ config ['controller_trigger'] \t ='c'; $ config ['function_trigger'] \t \t ='m'; $ config ['directory_trigger'] \t ='d'; –

+0

我認爲問題在於HTACCESS –

回答

1

如何添加2項目之一,在笨WordPress和其他

假設下面的目錄結構

www/ 
    .htaccess (wordpress htaccess) 
    index.php (wordpress index.php and files) 
www/backend/ 
    .htaccess (codeigniter htaccess) 
    index.php (codeigniter htaccess) 

爲WordPress的

//just add this line in wordpress htaccess 
<Directory "backend/"> 
    Allow from all 
</Directory> 

的.htaccess文件對於笨的.htaccess文件

//add this lines in your codeigniter htaccess 
RewriteEngine on 
RewriteBase /backend/ 
... 
RewriteRule ^(.*)$ /backend/index.php?/$1 [QSA,L] 

這種類型的工作,有每次我...

0

我不能評論還沒有,但對我來說似乎是你的 '的index.php' 是從URL中丟失:

https://example.com/team/abc/index.php/login/authenticateUserWeb 

可以發現:

https://example.com/team/abc/login/authenticateUserWeb 

不能(返回404)。

這些url之間的區別在於最後一個沒有/index.php/。

一些步驟,你可以檢查:

  • 是您笨的config.php適合您的測試後端的新位置? (BASE_URL)。
  • 看來你在url中使用index.php所以你沒有使用url的重寫來在沒有index.php的情況下工作。如果是這種情況,請確保config.php中的'index_page'設置正確(值:'index.php'可能就足夠了),而不是空的。
+1

這裏是我的配置文件:$ config ['base_url'] =「example.com/團隊/ ABC /「;; $ config ['index_page'] ='index.php'; $ config ['allow_get_array'] = TRUE; $ config ['enable_query_strings'] = FALSE; $ config ['controller_trigger'] ='c'; $ config ['function_trigger'] ='m'; $ config ['directory_trigger'] ='d'; –

+1

您的Codeigniter文件夾中是否有.htaccess文件,用'index.php'重寫url以從url中刪除'index.php'? 如果是這樣,使$ config ['index_page']中的值爲空字符串。 – Sharasuke

+1

不在codeigniter文件夾中,但我有.htaccess文件在wordpress –

相關問題