将 .htaccess 与 RewriteEngine 一起使用时出现 500 内部服务器错误

编程入门 行业动态 更新时间:2024-10-22 12:35:55
本文介绍了将 .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.

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

One of these rules is to make the url: mysite/upload point to: mysite/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 内部服务器错误

本文发布于:2023-11-01 01:29:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547851.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   服务器   htaccess   RewriteEngine

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!