I have developed a web application using codeigniter. In my localhost it works properly. But while i am hosting it to the live server (shared server) it's not working. I am getting the home page while calling the main URL on live server, but any URL through controller is not working
When calling the URL "http://my_domain.in/pages/second_page" getting the following error
The requested URL /my_domain.in/my_domain.in/index.php/pages/second_page was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache Server at my_domain.in Port 80
I noticed on the error string URL that my domain name is repeating but on actual URL it is not like that and index.php also found. So i have changed .htaccess codes so many times to solve this issue. That time the URL on Error message is changing but no successful result occurred.
At last i have hosted it on my friend's server. that time it works properly as like my localhost. Can you please tell me what will be the problem of my server? Is there anything to enable or disable while using codeigniter on that server? The codeigniter framework is never used in this server.
For getting better answer you need to provide the hosting provider name. You can try with the following .htaccess.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
It looks youare hiding the index.php but the error is mentioning it ==> /my_domain.in/my_domain.in/index.php/pages/second_page was not found
Did you remove it in the config page too? \config\config.php
make sure $config['index_page'] = ''; and add the .htaccess file with these lines
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
I had this problem when testing on Windows and Linux machines and adjusted the config.php like this.
if (file_exists(FCPATH.'.htaccess')) {
$config['index_page'] = '';
}
else {
$config['index_page'] = 'index.php';
}
First teste without the .htacsess file If all went well, place the .htaccess file in the root and try again.
If you still get this error, look at the links you have coded and see if the index.php is mentioned in it.