如何从文件夹调用代码点火器中的控制器


How to call controller in codeigniter from folder?

我有一个网站

  • 前端:WordPress
  • 后端:编码点火器

代码点火器实例保存在名为后端的文件夹中。

设置后端的测试环境。

  • 文件夹名称:团队
  • 代码点火器安装在:ABC文件夹

因此,路径将如下所示:

publichtml/team/abc

现在尝试登录时出现"404 未找到"错误

任何人都可以帮助我脚本中出了什么问题:

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

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

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

301 永久搬家

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

404 未找到

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

网络错误: 404 未找到

如何在代码点火器中添加 2 个带有 wordpress 和其他项目

假设以下目录结构

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

对于 HTACCESS 文件用于 wordpress

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

对于代码点火器 HTACCESS 文件

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

这种类型的每次对我来说都有工作...

我还不能发表评论,但对我来说,网址中似乎缺少您的"索引.php":

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

可以在以下情况下找到:

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

不能(返回 404)。

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

您可以检查的一些步骤:

  • 您的 Codeigniter 配置.php是否适应测试后端的新位置?(base_url)。
  • 似乎您在 url 中使用了 index.php,因此您没有使用 url 的重写来在没有 index.php 的情况下工作。如果是这种情况,请确保配置中的"index_page"设置是正确的.php(值:'index.php'可能就足够了)而不是空的。