2017-07-16 91 views
3

我在主public_html文件夾(http://www.myexample.com)中部署了一個使用CodeIgniter的網站。這個項目在localhost上完美運行。爲了從URL中移除的index.php這具有以下的.htaccess:活動主機上codeigniter中的內部服務器錯誤

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

然而,當我試着去的網站,我得到一個內部服務器錯誤:

Internal Server Error 

The server encountered an internal error or misconfiguration and was unable to complete your request. 

Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error. 

More information about this error may be available in the server error log. 

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. 

我已應用不同的.htaccess文件,但得到相同的錯誤。

+0

您已輸入有效的數據庫uesrname和密碼?也有你改變你的配置文件中的基礎url $ config ['base_url'] ='http://example.com';'它在'application/config/config.php' – Regolith

+0

是的,我做了這個設置,但仍然得到這個錯誤。 –

回答

4

我最常做的移植到活服務器時,如下所示
第一.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或更高版本,並檢查您的框架的服務器要求。

+0

仍然面臨相同內部服務器錯誤問題 –

+0

當我刪除.htaccess文件仍然給這個內部服務器錯誤msg –

+0

檢查Apache錯誤日誌,看看是否啓用了rewrite_module – Regolith

3

試試這個,它爲我工作。

RewriteEngine on 
DirectoryIndex index.php 
RewriteBase/
RewriteCond $1 !^(index.php|uiFiles|resources|robots.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
+0

仍然面臨同樣的問題。 –

+0

請勿使用代碼片段來格式化您的代碼! – Vickel

0

我有同樣的問題,但我想通了。

  1. 確保收集了所有數據庫配置。 在這裏你可以試試你的index.php(root);

    if(mysqli_connect('hostname','username','password','database')) { echo'ok'; }

    如果確定,然後轉到您的.htaccess文件。

  2. 在你的.htaccess文件,請保留此行空白

    RewriteBase/