Wednesday, January 19, 2011

Almost empty .htaccess file causing 500 error response

I created a test directory called "rewrite" and put a .htaccess file inside with a rewrite rule.

When I go to that URL through my browser I get a 500 Internal Server Error.

So I thought it was my rewrite syntax and tried a few changes, same thing. Then I commented out everything with # on each line. Same thing.

Then I noticed that the directory doesn't show up in its parent directory (which has no index file).

So then I tried changing the filename to .htaccess_bad, and the directory shows up.

Then I changed it back to .htaccess and emptied the file, so it a blank file. The directory still shows up.

Finally I added a single # to the .htaccess file, and viola, the directory disappears again.

I though the issue might be that the parent directory has a .htaccess file with a [R] flag on its rewrite rule, but removing that didn't fix the issue.

Any help on what to try next or why this is happening?


Quick update:

Even having a line break is causing issues. (so it has to be truly empty it seems).

  • Well, I've never had this issue before, but...

    When I opened up Putty and edited the .htaccess file server-side, it worked.

    That's one point off for Notepad++.

    From Anthony
  • I'm guessing that your .htaccess file is in DOS format and it needs to be in Unix format.

    From Dan

0 comments:

Post a Comment