31

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!

7 Answers 7

53

\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.

Sign up to request clarification or add additional context in comments.

2 Comments

ahhh I see. I used my FTP clients own editor to do the .htaccess, which is probably why this happened. Just did it with notepad and everything is fine now, thanks :)
you just saved my life! I couldn't figure out why my rewrite constantly gave a 500 error :) Saved it as Asci and it worked like a charm
28

It might be the mod_rewrite module is not loaded.

Windows xampp : Open xampp/apache/conf/httpd.conf and uncomment mod_rewrite module.
Windows wamp : Open wamp/bin/apache/Apache2.x.x/conf/httpd.conf and uncomment mod_rewrite module.
Ubuntu : a2enmod rewrite && service apache2 restart or cp /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

Then reload apache

Comments

11

To remove the BOM in unix use vi and below command

: set nobomb

: wq

Comments

10

Try this:

a2enmod rewrite /etc/init.d/apache2 restart 

Comments

2
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / rewriterule ^upload$ upload.php </IfModule> 

try this.

1 Comment

Nope, still coming up with a 500 error. Error log says: [alert] [client 81.179.29.185] /home/minecraf/public_html/.htaccess: </IfModule> without matching <IfModule> section
2

I had this problem and solved it with:

sudo a2enmod rewrite sudo service apache2 restart 

Comments

1

Just save your .htaccess file with UTF-8 encoding (without BOM) and upload. Recommended to use Notepad++. (in my case that helped).

atb

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.