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?
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';
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With