Welcome Guest, Not a member yet? Register   Sign In
404 on Live Server
#1

First, let me apologize for what must be a common question.  I couldn't find anything that directly addressed my problem.

My code works find on my local machine.  Locally, my directory structure is as follows (some extraneous files/folders not shown):

Code:
- (server)
 - [website]
   - application
     - (CodeIgniter material: models, views, controllers, etc.)
   - css
     - (CSS files here)
   - js
     - (JavaScript files here)
   - system
     - (CodeIgniter System material)
   - .htaccess

I've moved this to my online server.  Let's say it's located at mydomain.com.  I have replicated the above structure.  At public_html/mydomain, all contents of [website] from above are present.

I've made changes to two files as part of the deployment:  application/config/config.php and application/config/database.php.  Here are the changes I made to each:

Code:
// Old line from application/config/config.php

$config['base_url'] = 'http://localhost/mydomain';


// New line from application/config/config.php

$config['base_url'] = 'http://mydomain.com/';

Code:
// Old application/config/database.php

$db['default'] = array(
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '',
    'database' => '[local database name]',
    [other parameters unchanged and not shown here]
);


// New application/config/database.php

$db['default'] = array(
    'hostname' => '[server IP]',
    'username' => '[server database username]',
    'password' => '[server database password]',
    'database' => '[server database name]',
    [other parameters unchanged and not shown here]
);


I am using mod_rewrite to remove index.php from the URL.  Here is the entirety of my .htaccess file located at the root level of my website:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>


Again, this all works locally.  If I go to http://localhost/mydomain, everything works as intended.  However, when I go to http://mydomain.com, I get a 404 error.  If I dive in and try to grab a JavaScript file, for example http://mydomain.com/js/helper.js, I get the file I asked for.  So something is amiss in the CodeIgniter settings.

Any help is much appreciated.  I'm happy to provide more information upon request!
Reply
#2

Are the operating systems on both the development version and the live version the same? It's possible that you have a filename casing issue. CodeIgniter 3 requires the first letter of the controller name to be uppercase and, since Windows and Mac are not case-sensitive filesystems, you might not see it until it's running on a case-sensitive OS like Linux.

But more details about things would be helpful:
- OS of both platforms
- version of CodeIgniter you're using
- what exactly is happening. (blank screen, 500 error, etc)
Reply
#3

Thanks for the response, kilishan. Here are the details:

- My local system runs Windows, and the server runs Linux (CentOS, I believe). All of my controllers are named with a leading uppercase letter.

- I'm using CodeIgniter 3.0.1.

- On the server, I get a 404 Page Not Found error.
Reply
#4

File name should be named with uppercase as well.
Reply
#5

Also, do you default structure of CI? Or you moved out Application and System folders?
When you say 404 error page, is it CI styled error page or default server error page?
Reply
#6

Please verify that you've copied your .htaccess file up to the server. Also, ensure that the mod_rewrite is installed and loaded if you're running Apache (you can check with a phpinfo() page).
Reply




Theme © iAndrew 2016 - Forum software by © MyBB