php - 实时主机上的 codeigniter 内部服务器错误

标签 php .htaccess codeigniter internal-server-error

我在主 public_html 文件夹 (http://www.myexample.com) 中部署了一个使用 CodeIgniter 的网站。该项目在本地主机上完美运行。为了从 URL 中删除 index.php,它具有以下 .htaccess:

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 webmaster@its.org.pk 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 文件,但得到了同样的错误。

最佳答案

我在迁移到live server时通常做的事情如下
第一个.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/';

如果仍然出现无法连接的错误,请尝试验证数据库用户名、名称和密码,并尝试更改数据库密码以确保其正确

更新
检查文件权限并确保它是 644 和文件夹权限 755
还要检查 phpmysql 版本并确保 php 版本至少为 5.6 或更高版本并检查您的服务器要求框架。

关于php - 实时主机上的 codeigniter 内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45125796/

相关文章:

php - 从 URL (Joomla 3.3/3.4/3.5) 中删除 ID(类别和文章)

.htaccess - 避免根级别 301 上的过多重定向

php - 插入复制第一个插入,但不复制任何其他插入

php - 数据不保存在数据库中

php - 在 Codeigniter 中 hook 的目的是什么?我们为什么要创造?

PHP 在 HTML 文本中查找字符串并替换它

php - 从主到从的mysql结构复制,从数据完好无损

.htaccess - X-Robots-Tag - Noindex .htaccess 中的几个文件

php - 查找动态宽度的最大字体大小

PHP 需要获取一个对象的属性值,但是该属性有一个复杂的键