简体   繁体   English

$ .post到Codeigniter控制器/方法404页面未找到

[英]$.post to Codeigniter Controller/Method 404 Page Not Found

I have developed a Codeigniter prototype application and hosted with Godaddy.com during the development phase for testing purposes without issue. 我已经开发了Codeigniter原型应用程序,并在开发阶段与Godaddy.com托管,以进行测试而没有问题。 This application uses a combination of javascript, jquery, HTML5, CSS and PHP (Codeigniter Framework). 此应用程序结合使用了javascript,jquery,HTML5,CSS和PHP(Codeigniter框架)。 This week I have transferred the application to the clients server and have had many configuration issues but finally hit a wall. 这周,我已将应用程序转移到客户端服务器,并且遇到了许多配置问题,但最终遇到了麻烦。

The client set up a fresh install on a new Linux/Apache2 server with PHP5. 客户端使用PHP5在新的Linux / Apache2服务器上进行了全新安装。 mod_rewrite is enabled and allowoverride is set to all. 启用了mod_rewrite并将allowoverride设置为all。 The Apache2 settings (per the client are)... Apache2设置(每个客户端都有)...

Apache2配置

My .htaccess script(since this issue I have tried many different .htaccess versions)... 我的.htaccess脚本(由于这个问题,我尝试了许多不同的.htaccess版本)...

RewriteEngine On
RewriteBase /CI/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]  

My javascript code for posting serialized form data to PHP page... 我的JavaScript代码,用于将序列化表格数据发布到PHP页面...

        $.post('login_ctrl/authenticateuserlogon', $formData, function($responseData)
        {   
            $userAuthentication=$responseData.userAuthentication;

            if ($userAuthentication=='success')
            {
                window.location.href = "student_portal_ctrl";
            }
            else
            {                       
                $('#loginErrDiv').text('Username or Password is incorrect - Please try again.');
                return;
            }

        });         

My codeigniter file structure is... 我的codeigniter文件结构是...

-root /
       /CI
        /application
        /system
        /index.php
        /license.txt
        /.htaccess

When I post to this controller/method, the browser outputs... 当我发布到此控制器/方法时,浏览器输出...

找不到Firebug 404错误

-----EDIT----- - - -编辑 - - -

Sorry, forgot to include my config.php settings, here they are... 对不起,忘了包括我的config.php设置,这里是...

 $config['base_url'] = '';
 $config['index_page'] = '';
 $config['uri_protocol']    = 'AUTO'; //I have tested the app using all of codeigniters 
                                      //default URI Protocols

-----EDIT #2----- -----编辑#2 -----

This is the method on the controller that is receiving the 404 error 这是控制器上收到404错误的方法

    //AUTHENTICATE USER LOGIN FUNCTION
public function authenticateuserlogon()
{
    //SETTING $FORMDATA TO SERIALIZED POST DATA
    $formData = $this->input->post();

    //Sets the Method for the login_mdl
    $modelMethod=$formData['modelMethod'];

    //LOADING USER AUTHENTICATION LOGIN MODEL
    $this->load->model('login_mdl');


    //SENDING FORMDATA TO MODEL AND RETURING DATA TO $RESPONSEDATA
    $responseData = array();
    $responseData = $this->login_mdl->$modelMethod($formData);

    //OUTPUTTING JSON RESPONSE DATA BACK TO JAVASCRIPT          
    $this->output->set_output(json_encode($responseData));          
}

Use this .htaccess which is tested by me and working fine 使用这个经过我测试并可以正常运行的.htaccess文件

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /CI/

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.

    ErrorDocument 404 /index.php
</IfModule> 

and in your config.php file use this, 并在您的config.php文件中使用它,

$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];

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

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