Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 实时主机上的codeigniter中存在内部服务器错误_Php_.htaccess_Codeigniter_Internal Server Error - Fatal编程技术网

Php 实时主机上的codeigniter中存在内部服务器错误

Php 实时主机上的codeigniter中存在内部服务器错误,php,.htaccess,codeigniter,internal-server-error,Php,.htaccess,Codeigniter,Internal Server Error,我已经部署了一个网站,在主要的公共html文件夹(http://www.myexample.com)。该项目在本地主机上运行良好。为了从URL中删除index.php,它具有以下.htaccess: RewriteEngine on RewriteCond $1 !^(index\.php|public|\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)

我已经部署了一个网站,在主要的公共html文件夹
(http://www.myexample.com)
。该项目在本地主机上运行良好。为了从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文件,但得到了相同的错误。

试试这个,它对我有用

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]

在迁移到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/config.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
);
$config['base_url'] = 'http://example.com/';
如果仍然出现“无法连接”错误,请尝试验证数据库用户名、名称和密码,并尝试更改数据库密码以确保其正确

更新
检查文件权限并确保其为
644
,文件夹权限为
755


同时检查
php
mysql
版本,确保
php
版本至少为
5.6
或更高版本,并检查框架的服务器要求。

我也遇到了同样的问题,但我已经解决了

  • 确保所有数据库配置都已收集。 在这里,您可以在index.php(root)中进行尝试

    if(mysqli_connect('hostname','username','password','database')) { 回声‘ok’; }

    如果确定,则转到.htaccess文件

  • 在.htaccess文件中,将此行留空

    重写基/


  • 如果你在Ubuntu 16.04、18.04或20.04上,试试这个-

    sudo a2enmod重写
    并重新启动apache服务器
    systemctl重启apache2

    我希望它能解决您的问题,它对我有效。

    2021年6月更新 我刚刚发现,在正确验证DB凭据之后,.htaccess文件主要是导致问题的文件。我删除了我在cpanel上的内容,并上传了另一个Boom,它成功了


    仅针对未来用户

    您是否输入了有效的数据库uesrname和密码?您还更改了配置文件
    $config['base\u url']='http://example.com';
    它位于
    application/config/config.php
    是的,我进行了此设置,但仍然出现此错误。仍然面临相同的问题。仍然面临相同的内部服务器错误问题当我删除时。htaccess文件仍然给出此内部服务器错误msgcheck apache错误日志,并查看
    rewrite_module
    是否启用。请重试将“$config['uri_protocol']”更改为
    $config['REQUEST_uri']
    而不是
    AUTO
    [Sun Jul 16 00:01:14.395173 2017][:error][pid 47296][client 39.60.59.236:45548]Application.cpp:261:File”/home/itsorg/public_html/index.php中的SoftException可由组写入