如何从文件夹调用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
如何添加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]
这种类型的工作,有每次我...
我不能评论还没有,但对我来说似乎是你的 '的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'可能就足够了),而不是空的。
这里是我的配置文件:$ 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'; –
您的Codeigniter文件夹中是否有.htaccess文件,用'index.php'重写url以从url中删除'index.php'? 如果是这样,使$ config ['index_page']中的值为空字符串。 – Sharasuke
不在codeigniter文件夹中,但我有.htaccess文件在wordpress –
不知道,但我注意到,index.php文件已经从https://example.com/team删除/abc/index.php/login/authenticateUserWeb和url是像GET一样的变化https://example.com/team/abc/login/authenticateUserWeb –
这里是我的配置文件:$ 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'; –
我认为问题在于HTACCESS –