且构网

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

.htaccess mod_rewrite >500内部服务器错误

更新时间:2022-06-25 08:57:23

当您将配置指令放在 .htaccess 文件中时,并没有得到预期的效果,可能有很多事情会出错.

When you put configuration directives in a .htaccess file, and you don't get the desired effect, there are a number of things that may be going wrong.

最常见的问题是,httpd.conf 文件中的 AllowOverride 指令 未设置为使您的配置指令得到遵守.确保您没有对相关文件范围有效的 AllowOverride None.一个很好的测试是将垃圾放入 .htaccess 文件并重新加载页面.如果没有生成服务器错误,那么您几乎可以肯定 AllowOverride None 已生效.

Most commonly, the problem is that AllowOverride directive in httpd.conf file is not set such that your configuration directives are being honored. Make sure that you don't have a AllowOverride None in effect for the file scope in question. A good test for this is to put garbage in your .htaccess file and reload the page. If a server error is not generated, then you almost certainly have AllowOverride None in effect.

另一方面,如果您在尝试访问文档时遇到服务器错误,请检查您的 httpd 错误日志.它可能会告诉您 .htaccess 文件中使用的指令是不允许的.

If, on the other hand, you are getting server errors when trying to access documents, check your httpd error log. It will likely tell you that the directive used in your .htaccess file is not permitted.

[2010 年 9 月 17 日星期五 18:43:16] [警报] [客户 192.168.200.51]/var/www/html/.htaccess:此处不允许使用 DirectoryIndex

[Fri Sep 17 18:43:16 2010] [alert] [client 192.168.200.51] /var/www/html/.htaccess: DirectoryIndex not allowed here

这将表明您使用了 .htaccess 文件中从未允许的指令,或者您只是没有将 AllowOverride 设置为足以满足您使用的指令的级别.请查阅该特定指令的文档以确定是哪种情况.

This will indicate either that you've used a directive that is never permitted in .htaccess files, or that you simply don't have AllowOverride set to a level sufficient for the directive you've used. Consult the documentation for that particular directive to determine which is the case.

或者,它可能会告诉您在使用指令本身时出现语法错误.

Alternately, it may tell you that you had a syntax error in your usage of the directive itself.

[2008 年 8 月 9 日星期六 16:22:34] [警报] [客户 192.168.200.51]/var/www/html/.htaccess:RewriteCond:坏标志分隔符

[Sat Aug 09 16:22:34 2008] [alert] [client 192.168.200.51] /var/www/html/.htaccess: RewriteCond: bad flag delimiters

在这种情况下,错误消息应该针对您所提交的特定语法错误.

In this case, the error message should be specific to the particular syntax error that you have committed.

您必须在 httpd.conf 文件中将 AllowOverride 设置为All"或FileInfo",才能在 .htaccess 文件中获得 mod_rewrite 指令的权限.

http://httpd.apache.org/docs/2.2/howto/htaccess.html