简体   繁体   English

Codeigniter:所有页面都显示未找到 404 页面(codeigniter 的 404,而不是 apache 的)

[英]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.更换硬盘后,我现在使用 apache 的 htdocs 文件夹。 When I tried accessing my codeigniter project again, all pages show '404 Page Not Found'.当我再次尝试访问我的 codeigniter 项目时,所有页面都显示“404 页面未找到”。 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).它不是来自我的 Web 服务器,因为我可以看出错误消息来自 CodeIgniter(因为它是一个样式化的 404 错误页面)。

My Project has two controllers: ( Admin.php and Vendor.php ).我的项目有两个控制器:( Admin.phpVendor.php )。 These two were working just fine.这两个工作得很好。

Things I tried:我尝试过的事情:

  • Checked my config/config.php检查我的 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.尝试使用和不使用index.php访问我的控制器,以防我的 mod_rewrite 无法正常工作。 Still not working.还是行不通。

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

Change this改变这个

in Config.phpConfig.php 中

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

.htacess .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/';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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