我最常做的移植到活服務器時,如下所示
第一.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
那麼數據庫的用戶名和密碼
application/config/database.php
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'DATABASE_USERNAME',//database username here
'password' => 'DATABASE_PASSWORD',//database password here
'database' => 'DATABASE_NAME',//database name here
'dbdriver' => 'mysqli',
'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
);
然後在配置文件 application/config/config.php
$config['base_url'] = 'http://example.com/';
如果還是你得到錯誤提示無法連接,嘗試驗證數據庫用戶名,姓名和密碼,請嘗試更改數據庫密碼只是爲了確保其正確
UPDATE
檢查文件的權限,並確保它是644
和文件夾權限爲755
另請檢查php
,mysql
版本並確保php
版本已發佈5.6
或更高版本,並檢查您的框架的服務器要求。
您已輸入有效的數據庫uesrname和密碼?也有你改變你的配置文件中的基礎url $ config ['base_url'] ='http://example.com';'它在'application/config/config.php' – Regolith
是的,我做了這個設置,但仍然得到這個錯誤。 –