6

我是stackowerflow和apache的新手,如果我把这个线程放在错误的地方,我很抱歉..

有人可以帮我避免内部服务器错误吗?htaccess | apache2ctl | 回溯

我想要做的是将这些行添加到 htaccess.. 我的 htaccess 和 webserve 在没有这些行的情况下工作正常.. 但我需要将它们添加到 htaccess

RewriteEngine on
RewriteCond %{REQUEST_METHOD}^(TRACE|TRACK)
RewriteRule .* - [F]

Header set X-Frame-Options Deny
Header always append X-Frame-Options SAMEORIGIN**

一旦我输入上面的行,当我刷新网页时它就会给我这个错误

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.14 (Ubuntu) Server at 192.168.176.130 Port 80

有人可以给一些建议吗?任何帮助将不胜感激...

4

1 回答 1

10

首先,您需要启用所需的 apache 模块:

a2enmod rewrite headers

然后,在 apache 配置中,只有启用了所需的模块才能执行:

 <IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteCond %{REQUEST_METHOD}^(TRACE|TRACK)
   RewriteRule .* - [F]
 </IfModule>

 <IfModule mod_headers.c>
   Header set X-Frame-Options Deny
   Header always append X-Frame-Options SAMEORIGIN**
 </IfModule>

重新启动您的 Apache 服务器:

service apache2 restart

如果仍然有错误,请执行以下操作:

tail /var/log/apache2/error.log

您将看到详细的错误。

于 2013-12-16T13:20:41.903 回答