简体   繁体   中英

Codeigniter: All pages shows 404 page not found (codeigniter's 404, not apache's)

Recently, before my PC changed hard disk, I was using Virtual Host. After I changed hard disk, I am now using apache's htdocs folder. When I tried accessing my codeigniter project again, all pages show '404 Page Not Found'. It is not from my web server because I can tell the error message is from CodeIgniter's(because it is a styled 404 error page).

My Project has two controllers: ( Admin.php and Vendor.php ). These two were working just fine.

Things I tried:

  • Checked my config/config.php

     $config['base_url'] = ''; $config['index_page'] = 'index.php';

    then I tried changing it to:

     $config['base_url'] = 'http://localhost/Work%20Projects/Admin_Panel/';
  • Tried accessing my controllers with and without the index.php in case my mod_rewrite is not functioning. Still not working.

     http://localhost/Work%20Projects/Admin_Panel/index.php/admin http://localhost/Work%20Projects/Admin_Panel/admin

Change this

in Config.php

$config['base_url'] = '';
$config['index_page'] = 'index.php';

.htacess

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

NOTE : In my pc also having same problem. But when i upload to server its working perfectly.

so till that You use with

$config['base_url'] = 'http://localhost/Work%20Projects/Admin_Panel/index.php/';

when you uploading just add a domain name and run this works perfectly.

$config['base_url'] = 'https://stackoverflow.com/';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM