[Apache] 开启 .htaccess 后出现 500 错误的解决方法

在网站启用 .htaccess 文件后,如果 Apache 没有进行相应配置,则可能出现 500 Internal Server Error 错误,类似下图:
500

通常可以采用如下一些措施,通过修改 Apache 配置文件 httpd.conf 来解决这个问题。

可以配合 Apache 安装目录下的 logs/error.log 来定位问题。

1、开启 mod_rewrite 模块:
搜索并打开如下行的注释:

.htaccess 文件首先需要开启 mod_rewrite 模块才能使用。

2、开启 mod_filter 模块:
如果出现如下错误:
Invalid command 'AddOutputFilterByType', perhaps misspelled or defined by a module not included in the server configuration

搜索并打开如下行的注释:

3、开启 mod_deflate 模块:
如果出现如下错误:
.htaccess: Unknown filter provider DEFLATE

搜索并打开如下行的注释:

4、开启 mod_headers 模块:
如果出现如下错误:
.htaccess: Invalid command 'Header'

搜索并打开如下行的注释:

Add a Comment

您的电子邮箱地址不会被公开。 必填项已用*标注