【问题标题】:Internal Server Error in codeigniter on live host实时主机上的 codeigniter 中的内部服务器错误
【发布时间】:2017-12-20 21:39:27
【问题描述】:

我在 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 文件,但得到了相同的错误。

【问题讨论】:

  • 您输入了有效的数据库用户名和密码吗?您还更改了配置文件$config['base_url'] = 'http://example.com'; 中的基本网址,它位于application / config / config.php
  • 是的,我做了这个设置,但仍然出现这个错误。

标签: php .htaccess codeigniter internal-server-error


【解决方案1】:

2021 年 6 月更新

我刚刚发现在正确验证数据库凭据后,.htaccess 文件主要是造成问题的文件。我删除了我在 cpanel 上的内容并上传了另一个 Boom 成功了!

仅供未来用户使用

【讨论】:

    【解决方案2】:

    如果你使用的是 Ubuntu 16.04、18.04 或 20.04,试试这个-

    sudo a2enmod rewrite 并重新启动您的 apache 服务器 systemctl restart apache2

    我希望它能解决你的问题,它对我有用。

    【讨论】:

      【解决方案3】:

      我有同样的问题,但我想通了。

      1. 确保收集所有数据库配置。 在这里你可以试试你的 index.php (root);

        if(mysqli_connect('hostname', 'username', 'password', 'database')) { 回声“好”; }

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

      2. 在您的 .htaccess 文件中,将此行留空

        重写基础/

      【讨论】:

        【解决方案4】:

        迁移到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/';
        

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

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

        【讨论】:

        • 仍然面临同样的内部服务器错误问题
        • 当我删除 .htaccess 文件时仍然给出这个内部服务器错误消息
        • 检查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 中的 SoftException:文件“/home/itsorg/ public_html/index.php" 可以按组写
        【解决方案5】:

        试试这个,它对我有用。

        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]
        

        【讨论】:

        • 仍然面临同样的问题。
        猜你喜欢
        • 1970-01-01
        • 2017-01-26
        • 1970-01-01
        • 2015-06-13
        • 2016-05-10
        • 2015-10-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多