TroyGrosfield.com TroyGrosfield.com

Headline

GoDaddy, Windows, Linux, and .htaccess

Author
by Troy Grosfield
Date
August 13th, 2010
Category
Developer
Story

Problem

I was having a lot of difficulties getting my .htaccess file to work on GoDaddy.  Everything was running fine locally, but when I FTP’d all my content to the GoDaddy servers I was seeing a 500 Error message and couldn’t figure out why.  The guilty culprit was my .htaccess file.  I work on a windows machine at home and my hosting account is linux.  When I uploaded the .htaccess file I checked to apache logs to see what was being spit out.  Here’s some of what I saw:

../html/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps mis-spelled or defined by a module not included in the server configuration
../html/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps mis-spelled or defined by a module not included in the server configuration
../html/.htaccess: Invalid command '\xef\xbb\xbf', perhaps mis-spelled or defined by a module not included in the server configuration

WTF right?  Here’s what the .htaccess file was suppose to look like:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1

As you can see, the characters \xef\xbb\xbf were out of place and causing the error to occur.

Solution

My fix for this was to open putty, a SSH client, and create the file using the vi editor.

How

This assumes you have a little knowledge working with the command line and unix based commands.  Your knowledge only has to be basic here.  If you need a reference check out A quick reference list of vi editor commands from my alma mater.

  1. Download and open putty
  2. Enter your hostname or IP address to connect. (this should be your ftp settings username@YOUR_DOMAIN.com)
  3. You will then be prompted to login
  4. After successfully logging in, go into your html folder: $ cd html
  5. Open up the vi editor for the .htaccess file with the following command: $ vi .htaccess
  6. If the file already exists the content will be displayed, but don’t be fooled.  If you added the file using a windows machine you still won’t see this hidden characters in the file itself.  You need to delete that file and create a new one.
  7. Put the file in insert mode (just hit the ‘i’ key)
  8. Add the following content to the file:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*) index.php?/$1

  9. Get out of insert mode by pressing the escape key.
  10. Once you’re out of insert mode hit ctrl+: (control and semi-colon at the same time)
  11. Save and close the file: :wq

Note that even when you go back and run the $ dir command, you still likely won’t see your file because .htaccess files are generally hidden.  Now when you go back to access your files, the .htaccess file will take affect.

Tags
Comments
2 Comments »

2 Comments

Leave a reply

 
  1. Author
    faisal
    Date
    April 3rd, 2012 at 6:14 am
    Comment

    Hi
    i installed fresh copy of wordpress 3.3.1 and follow all steps for multisite setup as described on http://codex.wordpress.org/Create_A_Network. but when i click on login to login again. it says 500 internal server error. i dont know where is exactly problem can you please help me for this.

  2. Author
    John
    Date
    January 22nd, 2012 at 5:24 am
    Comment

    Thank you , but there is a very simple solution by edit the htaccess file in notebad++ and save it as utf8 without BOM. and upload it again .