Lance
Lance

Reputation: 4820

CodeIgniter default page on remote server

I'm relatively new to CI and I'm wondering if anyone knows how to set the default page of CI. I just transferred my files from my local server to my remote server and am having some problems. Firstly, I think it's important to note that I edited the .htaccess file so that the index.php was removed from the URL.

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

Secondly, in my config.php file, I have:

$config['base_url'] = '';
$config['index_page'] = 'sportstream';

sportstream is the name of a controller that is found in the application/controllers/ folder. From my experiences without using CI (or any other framework), the index.php file inside of the public_html folder on the remote server is the one that is loaded by default upon visiting a site. But, with CI, whenever I try to visit my domain name, a 404 error is returned. I have tried setting to base_url to http://www.mysite.com without any luck.

Does anyone here know how to make it so that upon visiting http://www.mysite.com that http://www.mysite.com/sportstream will be loaded?

Upvotes: 5

Views: 1484

Answers (2)

doitlikejustin
doitlikejustin

Reputation: 6353

You need to add a RewriteBase in your .htaccess file:

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

NOTE: I have added a ? after the index.php as well.

I would also set the follow to an empty string (after you have tried the above):

$config['base_url'] = '';
$config['index_page'] = '';

Finally, in your routes.php file:

$route['default_controller'] = 'sportstream';

Update

In application/config/database.php you need to change your database driver. On your localhost, MySQLi was the database driver set. On your remote server, however, MySQLi was not installed, so changing it to MySQL should fix the issue.

//old - works on local server
$db['default']['dbdriver'] = 'mysqli';

//new - works on remote server
$db['default']['dbdriver'] = 'mysql';

For some reason, Codeigniter just "breaks" and shows the blank screen with no errors.

Upvotes: 3

Avin Varghese
Avin Varghese

Reputation: 4370

You have to set default controller in $route['default_controller'] ="sportstream"; it is located in aplication/config/route.php, So when visitinghttp://www.mysite.com/thesportstream` controller will be loaded by default.

Check about default controller in User guide

Switch back the $config['index_page'] = '';

If you renamed the index.php then you must enter the index_page name in config or else you can keep it blank.

Recommended Codeigniter starter guide: http://net.tutsplus.com/tutorials/php/codeigniter-basics/

Upvotes: 0

Related Questions