繁体   English   中英

如何从文件夹中的codeigniter中调用控制器?

[英]How to call controller in codeigniter from folder?

我有一个网站

  • 前端 :WordPress
  • 后端 :codeigniter

Codeigniter实例保存在名为backend的文件夹中。

设置后端测试环境为。

  • 文件夹名称 :团队
  • codeigniter安装在: abc文件夹中

因此,路径将为:

publichtml /团队/ ABC

现在尝试登录时出现404 not found错误

谁能帮我解决脚本中的问题:

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

});

    }

现在,当我尝试登录时在控制台日志中发现以下错误:

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

301永久移动

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

找不到404

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

NetworkError:找不到404

如何在Codeigniter中使用Wordpress和其他添加两个项目

假设下面的目录结构

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

对于Wordpress的HTACCESS文件

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

对于Codeigniter HTACCESS文件

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

这种类型的工作对我来说都是无休止的...

我还不能发表评论,但对我来说,URL中似乎缺少您的“ index.php”:

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

可以在以下时间找到:

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

不能(返回404)。

这些网址之间的区别在于,最后一个没有/index.php/。

您可以检查一些步骤:

  • 您的Codeigniter config.php是否适应测试后端的新位置? (BASE_URL)。
  • 似乎您在url中使用index.php,因此您没有在没有index.php的情况下使用URL重写。 如果是这种情况,请确保config.php中的“ index_page”设置正确(值:“ index.php”可能就足够了)并且不为空。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM