2

I have developed a Codeigniter prototype application and hosted with Godaddy.com during the development phase for testing purposes without issue. This application uses a combination of javascript, jquery, HTML5, CSS and PHP (Codeigniter Framework). 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. mod_rewrite is enabled and allowoverride is set to all. The Apache2 settings (per the client are)...

Apache2 Configuration

My .htaccess script(since this issue I have tried many different .htaccess versions)...

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...

        $.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...

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

When I post to this controller/method, the browser outputs...

Firebug 404 Not Found Error

-----EDIT-----

Sorry, forgot to include my config.php settings, here they are...

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

-----EDIT #2-----

This is the method on the controller that is receiving the 404 error

    //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));          
}
Matthew Witt
  • 145
  • 1
  • 2
  • 9

1 Answers1

3

Use this .htaccess which is tested by me and working fine

<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['base_url'] = "http://".$_SERVER['HTTP_HOST'];
Deepak
  • 6,684
  • 18
  • 69
  • 121
  • I have updated both the code and .htaccess. Now when I submit the form, I am receiving a "NetworkError: 500 Internal Server Error - http://65.44.222.164/CI/login_ctrl/authenticateuserlogon" instead of a 404 Not Found error – Matthew Witt Sep 28 '13 at 06:03
  • yes which means you got error in your code. please check your apache error logs – Deepak Sep 28 '13 at 06:04
  • can you post your `authenticateuserlogon` method ? – Deepak Sep 28 '13 at 06:16
  • First, thanks for your patience because I am going crazy. :) Here are my apache error logs when for the 500 error [debug] mod_deflate.c(615): [client 98.154.88.186] Zlib: Compressed 1166 to 527 : URL /CI/index.php – Matthew Witt Sep 28 '13 at 06:17
  • [debug] mod_deflate.c(615): [client 98.154.88.186] Zlib: Compressed 1166 to 527 : URL /CI/index.php [debug] mod_deflate.c(615): [client 98.154.88.186] Zlib: Compressed 92651 to 32770 : URL /CI/js/jquery-1.9.1.min.js, referer: http://65.44.222.164/CI/ [debug] mod_deflate.c(615): [client 98.154.88.186] Zlib: Compressed 3089 to 1061 : URL /CI/css/login.css, referer: http://65.44.222.164/CI/ [debug] mod_deflate.c(615): [client 98.154.88.186] Zlib: Compressed 2638 to 1111 : URL /CI/js/login.js, referer: http://65.44.222.164/CI/ – Matthew Witt Sep 28 '13 at 06:18
  • these are debug logs. i cant see any logs with respect to your 500 page error. are you sure there is nothing on the error_logs ? – Deepak Sep 28 '13 at 06:24
  • Is there a different set of error logs I can view - I am using a Macbook Pro and running this SSH command from the terminal to see the Apache error logs... tail -f /var/log/apache2/error.log – Matthew Witt Sep 28 '13 at 06:27
  • Thanks for the help, it ended up being the call to load my database. When I entered my clients MySQL database settings I just assumed it would work. Not sure why codeigniter or the browswer didn't kick out a better error than just 500 internal server error. – Matthew Witt Sep 28 '13 at 16:55