且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

codeIgniter PHP的Apache 500内部服务器错误

更新时间:2022-11-30 20:38:46

开放的httpd.conf一般设在Apache的安装目录窗口

Open httpd.conf generally located in Apache installation directory in windows

/apache/conf/httpd.conf

/etc/httpd/httpd.conf

在基于Unix的系统。 httpd.conf文件是存储有关服务器的各种信息的Apache配置文件。

in Unix based systems. httpd.conf is an Apache configuration file which stores various information about the server.

搜索模块 mod_rewrite.so 或( mod_rewrite.c 在极少数情况下)。 mod_rewrite的模块被显影以改写在飞行所请求的URL。大多数时候,你会发现在注释状态。

Search for the module mod_rewrite.so or (mod_rewrite.c in rare cases). mod_rewrite module is developed to rewrite the requested URLs on the fly. Most of the time you will find in commented state.

#LoadModule rewrite_module模块/ mod_rewrite的。*

下面字符重新presents这是评论或禁用。

Here # character represents that it is commented or disabled.

的LoadModule rewrite_module模块/ mod_rewrite的。*

删除并且使用命令重新启动Apache HTTP服务器阿帕奇-k在Windows重新启动服务的httpd重新启动在UNIX系统。您还可以使用XAMPP / WAMP的用户界面在Windows系统重新启动Apache。

Remove # and restart the Apache Http Server using the command apache -k restart in windows or service httpd restart in unix systems. You also use XAMPP/Wamp UI to restart Apache in windows systems.

接下来,创建的.htaccess 在根目录下的文件,你的codeIgniter项目位于粘贴以下code

Next create .htaccess file in root directory where your CodeIgniter project is located and paste following code

# index file can be index.php, home.php, default.php etc.
DirectoryIndex index.php

# Rewrite engine
RewriteEngine On

# condition with escaping special chars
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

接下来查找codeIgniter配置文件,一般位于它的配置目录。

Next Find CodeIgniter configuration file, generally located in it's configuration directory.

./的application / config / config.php文件

打开文件,并 $配置['index_page'] 值为空。它看起来像这样

Open the file and make $config['index_page'] value empty. which looks like this

/*
  |--------------------------------------------------------------------------
  | Index File
  |--------------------------------------------------------------------------
  |
  | Typically this will be your index.php file, unless you've renamed it to
  | something else. If you are using mod_rewrite to remove the page set this
  | variable so that it is blank.
  |
 */
$config['index_page'] = '';

现在的故事结束。应当一切正常。您可以找到有关httpd.config在更多信息 Apache模块的mod_rewrite 。希望这可以帮助你。谢谢!

Now the story is ended. Everything should work fine. You can find more information about httpd.config at Apache Module mod_rewrite. Hope this helps you. Thanks!!