【问题标题】:500 Internal Server Error CodeIgniter htaccess mod_rewrite500 内部服务器错误 CodeIgniter htaccess mod_rewrite
【发布时间】:2014-08-21 15:50:46
【问题描述】:

我在 Windows 上编写了我的 Web 应用程序,并将其推送到运行 Ubuntu Linux 的服务器上。这是我的 .htaccess 文件:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /SearchDatGifUbuntu/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.
  ErrorDocument 404 /index.php
</IfModule>

我在 /etc/apache2/sites-available/default 的文件如下:

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

我在我的 ubuntu 服务器的命令行中输入了 sudo a2enmod rewrite,它说 mod_rewrite 已经打开。

当我通过我的 codeigniter 应用程序进行调试时,错误似乎出现在 CodeIgniter.php 的第 308 行,即:

$CI = new $class();

谁能告诉我这是怎么回事?

【问题讨论】:

标签: php .htaccess codeigniter mod-rewrite ubuntu


【解决方案1】:

在您的 CI 项目文件夹中创建一个 .htaccess 文件。 在文件中输入以下代码。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

【讨论】:

    【解决方案2】:

    我必须编辑:

    /etc/apache2/apache2.conf

    并设置:

    <Directory /var/www/html>
        # ... other directives...
        AllowOverride All
     </Directory>
    

    然后重启apache,以便读取上面的.htaccess代码。

    【讨论】:

      【解决方案3】:
      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php/$1 [L]  
      

      试试这个 .htaccess 代码,然后重启你的 apache

      如果这不起作用,请尝试此链接

      How to enable mod_rewrite for Apache 2.2

      【讨论】:

        猜你喜欢
        • 2018-05-10
        • 2011-07-09
        • 1970-01-01
        • 2012-05-01
        • 2016-04-15
        • 2016-09-22
        • 2017-04-05
        • 1970-01-01
        • 2013-02-06
        相关资源
        最近更新 更多