将 .htaccess 与 RewriteEngine 一起使用时出现 500 内部服务器错误 [英] 500 Internal Server Error when using .htaccess with RewriteEngine

查看:28
本文介绍了将 .htaccess 与 RewriteEngine 一起使用时出现 500 内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在共享主机 Bounceweb 上,我正在尝试添加一些重写规则以使我的链接看起来更漂亮.

I am on the shared host Bounceweb and I am trying to add some rewrite rules to make my links look prettier.

这些规则之一是使网址:http://mysite.com/upload 指向:http://mysite.com/upload.php.我的 .htaccess 文件中有这个:

One of these rules is to make the url: http://mysite.com/upload point to: http://mysite.com/upload.php. I have this in my .htaccess file:

RewriteEngine on
RewriteRule ^upload$ upload.php

但它给我的只是一个 500 内部服务器错误.我查看了我的日志,发现很多:

but all it's giving me is a 500 Internal Server Error. I looked at my logs and this comes up a lot:

[alert] [client 81.179.29.185] /home/minecraf/public_html/.htaccess: Invalid command 'xefxbbxbfRewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

这是否意味着我的主机不支持 .htaccess?如果他们不这样做,那就太蹩脚了.我已经尝试将 .htaccess 的权限更改为 777,但没有帮助.

Does this mean my host doesn't support .htaccess? Pretty lame if they don't. I've already tried changing the permissions of .htaccess to 777 and it doesn't help.

谢谢!

推荐答案

xefxbbxbf 是三个不可见的垃圾字符(至少从 Apache 的角度来看),称为 Unicode BOM,或字节顺序标记.Apache 认为这些字符是紧随其后的命令的一部分.这是您在日志中看到的内容,尽管字符已被转义,因此它们是肉眼可见的.xefxbbxbfRewriteEngine

xefxbbxbf are three invisible junk characters (at least from Apache's perspective) called the Unicode BOM, or byte order mark. Apache thinks that those characters are part of the command that follows right after. This is what you see in the log, though the characters are escaped so they're visible to the naked eye. xefxbbxbfRewriteEngine

在您的编辑器中,尤其是当您的编辑器是记事本时,请确保您保存的文件没有 BOM.这应该可以在另存为对话框或其他地方选择.

In your editor, especially if your editor is Notepad, make sure you're saving your file without a BOM. This should be selectable in the save as dialog or elsewhere.

这篇关于将 .htaccess 与 RewriteEngine 一起使用时出现 500 内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆