Codeigniter website 404 error / .htaccess

2020-05-06 09:17发布

问题:

I'm trying with codeigniter, I build a small web that working fine in local but when I uploaded to my free hosting (http://www.hostinger.es) then don't work. I think it is because the .htaccess and I'm reading and trying some .htaccess configurations but still don't work.

My CodeIgniter proyect is in mydomain/admin because the rest of web is not codeigniter:

Some options of my config.php

$config['base_url'] = 'http://whereis.hol.es/admin';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '.html';

And my last .htaccess, I'm try to get simple as possible to understand it.

RewriteEngine on
RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

It's my first time with htaccess files, I'm reading to learn, but I can't get my web online. I don't know sure where put the .htaccess file: - / of my website - / of my codeigniter (admin) - application codeigniter folder (admin/application)

PD: When I try to load admin it redirect to my controller Login but show a 404 error: 404 Page Not Found

The page you requested was not found.

回答1:

Use the following code in your .htaccess file

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