内部服务器错误 - htaccess

问题描述 投票:83回答:6

我有一个htaccess文件,它在主机上完美运行但是当我把它放在本地时,它显示我这个错误:

内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求。

请联系服务器管理员admin @ localhost并告知他们错误发生的时间,以及可能导致错误的任何操作。

服务器错误日志中可能提供了有关此错误的更多信息。

我在错误日志文件中找到了此警报:

[Tue Apr 17 10:02:25 2012] [alert] [client 127.0.0.1] D:/wamp/www/jivan/sql/.htaccess:无效的命令'Header',可能拼写错误或由未包含在内的模块定义服务器配置

这是我的htaccess文件代码:

  RewriteEngine On
AddDefaultCharset utf-8
RewriteRule ^([0-9-]+)/keyword_show.html$ keyword_show.php?keyword_id=$1
RewriteRule ^page_(.*).html$  page.php?url=$1
RewriteRule ^([0-9-]+)/(.*)/(.*)/(.*).html$ $2.php?advertisement_cat=$1&id=$3&pagenumber=$4
RewriteRule ^([0-9-]+)/(.*)/(.*).html$ $2.php?advertisement_cat=$1&pagenumber=$3
RewriteRule ^([0-9-]+)/(.*).html$ $2.php?advertisement_cat=$1
# cache images and flash content for one month
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>

# cache text, css, and javascript files for one month
<FilesMatch ".(js|css|pdf|txt)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>

我的本地服务器由wamp运行,我也启用了重写模块!

那么问题是什么?!!

.htaccess wamp
6个回答
122
投票

Header指令位于mod_headers apache模块中。您需要确保将模块加载到apache服务器中。


91
投票

启用HEADERS模块的步骤

$ cd /etc/apache2/mods-available
$ sudo a2enmod headers
$ /etc/init.d/apache2 restart

33
投票

在您的命令行上:

安装mod_headers

sudo a2enmod headers

然后重启apache

service apache2 restart

12
投票

试试这个:

<IfModule mod_headers.c> Header set [your_options] </IfModule>

安装/启用后你重启了WAMP吗?


6
投票

在Ubuntu / Debian机器中,您只需运行以下命令:

sudo ln -s /etc/apache2/mods-available/headers.load /etc/apache2/mods-enabled/

应该全部.....


0
投票

这个答案适合我

<IfModule mod_headers.c> Header set [your_options] </IfModule>
© www.soinside.com 2019 - 2024. All rights reserved.