I am using Codeigniter in Local WAMP. Here code is working fine. But i upload in Cpanel ( inside of example.com, folder name call \'mysite
\'). Ther
There are few things that you have to take into consideration. when you setup your project with codigniter framework. following is the file that you have to make changes.
1).htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /mysite/index.php/$1 [L]
2)application/config/config.php
$config['base_url'] = 'http://example.com/mysite/';
$config['server_root'] = $_SERVER['DOCUMENT_ROOT'];
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
3)application/config/database.php
$db['default']['hostname'] = 'localhost'; // set your hostname
$db['default']['username'] = 'root'; // set database username
$db['default']['password'] = 'root'; //set database password
$db['default']['database'] = 'XYZ'; //set your database name
$db['default']['dbdriver'] = 'mysql';
4)application/config/routes.php
$route['default_controller'] = "user"; //your default controller
$route['404_override'] = '';
Note: your .htaccess file must be in root directory. here it should be in mysite folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
$config['base_url'] = 'http://example.com/mysite/';
Better than :
$config['base_url'] = 'http://example.com/mysite';
Try this :
RewriteBase /
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /mysite/index.php/$1 [L]
CodeIgniter can be told to load a default controller when a URI is not present, as will be the case when only your site root URL is requested.So once replace your default conroller 'welcome' with your conrtoller in routes.php , it may help you
Sometimes "ORIG_PATH_INFO" fixes this issue. So you can also try again with changing uri_protocol to "ORIG_PATH_INFO"
$config['uri_protocol'] = "ORIG_PATH_INFO";
and the base_url should be absolute,
$config['base_url'] = "http://example.com/mysite/";
Open config.php and do following replaces
$config['index_page'] = "index.php"
to
$config['index_page'] = ""
In some cases the default setting for uri_protocol does not work properly. Just replace $config['uri_protocol'] ="AUTO" by $config['uri_protocol'] = "REQUEST_URI"
HTACCESS
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]