【问题标题】:Code-igniter site moved to localhost to liveCode-igniter 网站移至本地主机
【发布时间】:2015-06-30 03:41:50
【问题描述】:

我已经使用 codeigniter 创建了网站,它在我的本地主机中运行良好。 CI 项目路径是 http://www.xxxxxxx.com/themes/NPOS。我对以下文件进行了以下修改。数据库连接正常。

.htaccess 文件

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

config.php

$config['base_url'] = 'http://www.xxxxxxx.com/themes/NPOS/';

* ******服务器启用了 mod_rewrite。********* *

在我尝试访问我的网站后,它给出了 404 Not found 错误

找不到

在此服务器上找不到请求的 URL /themes/NPOS/login。

是什么原因,请给点建议。

【问题讨论】:

  • 试试themes/NPOS/而不是/themes/NPOS/
  • @Umair 试过了,但没用
  • 您的.htaccess 中缺少RewriteEngine On

标签: php .htaccess codeigniter mod-rewrite


【解决方案1】:

在 config.php 中,做这个修改

路径:config/config.php

$config['base_url'] = '';
$config['index_page'] = '';
$config['encryption_key'] = '123';

然后在database.php中

路径:config/database.php

如果 CI 2.0

$db['default']['hostname'] = 'localhost';//if cPanel this will be loacalhost
$db['default']['username'] = '';//username which create by server
$db['default']['password'] = '';//password
$db['default']['database'] = '';//database name

如果 CI 3.0

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => '',//username which create by server
    'password' => '',//password
    'database' => '',//database name

如果CPanel托管可以通过数据库向导

打开

然后 .htaccess 文件将是(这应该是 应用程序文件夹之外的地方

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

【讨论】:

    猜你喜欢
    • 2015-06-09
    • 2016-05-08
    • 2020-10-09
    • 2019-07-04
    • 2023-03-25
    • 1970-01-01
    • 2012-09-18
    • 2018-11-18
    • 2017-02-02
    相关资源
    最近更新 更多