• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI system can't see default controller set in config/routes

#1
I've been stuck on this for several days now. I'm attempting to deploy CI 3+ app to GoDaddy server (Linux, CPanel), shared hosting acct.

I've placed myapp in subfolder 'CIP17'  directly below public_html folder that's below my acct root directory.

I have a non-CI version of this app in another subfolder at the same level that works OK.

The new CI version works OK on my localhost.

I want myapp to open at login page, login controller: 'c_login', Login controller file: 'c_login.php', 'class C_login extends CI_Controller   { . . . }

I also placed the CI 'Welcome' controller in same controller folder and the CI 'welcome_message' in my views folder.

In config/routes file:

    $route['default_controller'] = 'c_login'; (I did try 'C_login', no joy.)
    $route['404_override'] = '';
    $route['translate_uri_dashes'] = FALSE;

In config/config file:
    $config['base_url'] = 'https://myapp.com/CIP17/';
    $config['index_page'] = ''; //index.php';
    $config['uri_protocol']    = 'REQUEST_URI'; //'QUERY_STRINGS'; // 'PATH_INFO'; //

I have an .htaccess file in the /CIP17/ app folder that seems to be working so that I don't need 'index.php in every URI  - although I only have a vague understanding of what these commands do individually:
    RewriteEngine On
    RewriteBase /CIP17/
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]

When I load 'https://myapp.com/CIP17/' to browser address bar I get: '404 Page Not Found'

When I type 'https://myapp.com/CIP17/c_login' in browser address bar I get: '404 Page Not Found'.

WhenI type 'https://myapp.com/CIP17/index.php/c_login' in browser address bar I get: '404 Page Not Found'.

When I type 'https://myapp.com/CIP17/C_login' in browser address bar I get: '404 Page Not Found'.

When I type 'https://myapp.com/CIP17/Welcome' in browser address bar I get the CI Welcome page.

I changed filename of 'Welcome.php' to 'Welcomex.php'  and tried 'https://myapp.com/CIP17/Welcomex.php'. I got '404 Page Not Found'. But when I changed the file names back to 'Welcome.php' I got the Welcome page again.

Finally, I tried renaming 'c_login.php' to Welcome.php and when trying 'https://myapp.com/CIP17/Welcome' in browser address bar I got the '404 Page Not Found' error. But when I did this and also changed the class declaration to: 'class Welcome extends CI_Controller   {...} This time I got a blank page - no 404 error. The contents  inspector showed empty html and body tags.

Any suggestions on how I'm screwing up would be greatly appreciated. Even just an idea of where I should look would be helpful at this point.
Reply

#2
If you change the filename you also have to change the class name within the file.

Your config index page looks strange too, should just be 'index.php' or '' since it seems you are using htaccess to override that.

At a quick glance your htaccess looks good.

Try removing the htaccess first of all and see if that changes anything. Until you can navigate to your new page beyond welcome it might help if you first remove that and put your 'index.php' back into your config.

Hope that helps.
Reply

#3
(06-05-2017, 11:12 AM)PaulD Wrote: Paul,

If you change the filename you also have to change the class name within the file.

Sorry if my post wasn't clear on that . . .

"Finally, I tried renaming 'c_login.php' to Welcome.php and when trying 'https://myapp.com/CIP17/Welcome' in browser address bar I got the '404 Page Not Found' error. But when I did this and also changed the class declaration to: 'class Welcome extends CI_Controller   {...} This time I got a blank page - no 404 error. The contents  inspector showed empty html and body tags."

I suspect this could be a good clue for someone who understands this better than I do.


Your config index page looks strange too, should just be 'index.php' or '' since it seems you are using htaccess to override that.

Yes, it was just $config['index_page'] = '';
That's 2 single guotes to make it blank. The //'index.php' after that was just the commented out previous content.


At a quick glance your htaccess looks good. Try removing the htaccess first of all and see if that changes anything. Until you can navigate to your new page beyond welcome it might help if you first remove that and put your 'index.php' back into your config.

OK. I took out the .htaccess and tried several versions of the address line including replacing the $config['index_page'] = ''; 
. . . with $config['index_page'] = 'index.php';  . . . and all variations in the address bar I could think of including the expected  https://myapp.com/CIP17/index.php/c_login
  . . . and got the 404 errors as before.

When I tried [i]https://myapp.com/CIP17/index.php/Welcome . . . [/i]I got the welcome page OK. But thanks for the suggestions.
Reply

#4
If you only want a single application with "pretty_urls" then use the recommended .htaccess file:

https://www.codeigniter.com/user_guide/g...t=htaccess

Also install the standard index,php in the root and set the $system and $application paths.

The Godaddy htaccess may not work if the relevant Apache redirection modules are not installed.
download and make your system directory strict
Reply

#5
Thanks for the advice John. I found last nite that I could call a simple 'test' controller that I wrote like the 'Welcome' controller that loads a simple view. I now suspect I can't load my other controllers because I did not transfer over all the necessary files from my localhost installation or maybe there are other folders/files I need to add. And probably some constants or config settings that need to be changed.

I've been working on this app for several months on my local server. This is my first attempt to deploy a CI package on a remote host. Basically I just copied the application, system and assets folders. I didn't even change the database connection constants for the new mysql location on the server. Thought I'd get something working and then take care of the details. Guess there are more details to deal with before I can really see much.

Added: I just found that on the remote server (Linux based) the controller file name must be first char upper case - same as the class name. I don't understand this since my existing app (the earlier not-CI version) has lower case file names for all controllers, models and views. This php-based web app has been running fine for several months. Must be a CI requirement that doesn't appear on a xampp server running under Windows. Very confusing.
Reply

#6
Linux is case sensitive with file name. Windows in NOT.
Thats why lower-case file names work on Windows but when you copy to a Linux server you get issues.
Always make sure to also Use capitalization on the local windows environment.
On the package it said needs Windows 7 or better. So I installed Linux.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.