Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

500 Internal Server Error when using .htaccess with RewriteEngine

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

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 

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 '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by a module not included in the server configuration 

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.

Thanks!

like image 992
Josh Avatar asked Mar 21 '11 02:03

Josh


People also ask

How do I know if htaccess rewrite is working?

First, visit https://htaccess.madewithlove.be. Then, enter your site's url and your . htaccess rewrite rule in the appropriate fields. Click Check Now.

What is htaccess Rewritecond?

htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.


1 Answers

\xef\xbb\xbf 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. \xef\xbb\xbfRewriteEngine

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.

like image 130
nitro2k01 Avatar answered Sep 21 '22 19:09

nitro2k01