404页面未找到:在CodeIgniter中请求的页面未被找到。

3
我们的代码如下:

以下是我们的代码

应用程序/配置/config.php

$config['base_url'] = 'http://myworldmirror.com/';  
$config['index_page'] = 'index.php/home';

.htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Options -Indexes

application/config/database.php

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'newsels1',
    'password' => 'newsels1',
    'database' => 'newsels1',
    'dbdriver' => 'mysql',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

输出

当我打开这个网址 "http://myworldmirror.com/",出现了以下的输出:

错误图片


config['index_page'] = 'index.php/home'; 更改为 config['index_page'] = ''; - Mohammad
你好,Mohammad。请尝试这段代码,但是显示了同样的错误。 - Nxsol Team
解决了我的问题:谢谢兄弟。 - Nxsol Team
3个回答

3

尝试这个:

$config ['index_page'] ='index.php/home';更改为$config ['index_page'] ='';

.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

请检查 application/config/routes.php 中的默认控制器数值。

$route['default_controller'] = 'welcome';

检查 application/controllers/Welcome.php 是否存在,否则根据需要更改 $route['default_controller'] 的数值。


你确定你能设置有效的default_controller值吗? - Shailesh Chauhan
$route['default_controller'] 的值是什么? - Shailesh Chauhan
$route['default_controller'] = 'home' & controller/home.php 可用 - Nxsol Team
请将 controller/home.php 重命名为 controller/Home.php。 - Shailesh Chauhan
解决了我的问题:谢谢兄弟。 - Nxsol Team

2

由于我无法为您的问题提供准确的解决方案,请尝试以下方法。如果其中一个方法有效,则我们可以找到解决方案。

  1. 删除您的 .htaccess 文件并更新 $config['index_page'] = ' '; 然后尝试访问 URL: http://myworldmirror.com/index.php/home 或者 http://myworldmirror.com/index.php。(如果此方法有效,那么您的 .htaccess 文件存在问题)。

  2. 在 config/database.php 中将 'dbdriver' => 'mysql' 替换为 'dbdriver' => 'mysqli',然后尝试。

请告诉我结果。


解决了我的问题:谢谢兄弟。 - Nxsol Team

2

http://myworldmirror.com/Home 已经可以使用。

请您进行更改。

$route['default_controller'] = 'Home';

为了

$route['default_controller'] = 'home';

@NxsolTeam 现在修复了吗? - Mohammad
解决了我的问题:谢谢兄弟 - Nxsol Team

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接