Quantcast
Channel: Charles on Software » apacheCharles on Software
Viewing all articles
Browse latest Browse all 3

.htaccess causes “500 Internal Server Error” with apache 2.2

$
0
0

I was adding 301 redirect rules to an .htaccess file for a client.  I had converted a site from static HTML to PHP, and wanted to make sure that external links were not broken.  After uploading the changes to the server and testing, I got the following error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

After a bit of head scratching I realized that one of the file names contained a space. I hadn’t spotted it because I’d generated the redirection rules via a Ruby script, rather than typing them all in by hand:

Redirect 301 /foo bar.html http://www.example.com/foo bar.php

This space was causing apache to throw an error when parsing the file. Enclosing the URLs in quotation marks solved the problem.

Redirect 301 "/foo bar.html" "http://www.example.com/foo bar.php"

Normally I try to avoid filenames with spaces in them when creating web-sites.  This site, however, was created by someone else and I was making a very specific change to it that required converting the files to PHP.  I automated as much of it as possible, mass renaming files and using search and replace across all files.  As a result, I never realized that one of the filenames contained a space until I found the problem above.


Viewing all articles
Browse latest Browse all 3

Trending Articles