404 Not Found Pretty URLs with GoDaddy and PHP
Posted by Matt Soukup at 12/03/2011, 02:13 AM CST
Back in the day, if you read a news article online and eyed your address bar, you might have seen something like
http://domain/article.php?article_id=1283721917
Nowadays, that same article is more likely linked by
http://domain/article/study-proves-fluoride-brain-damage/
Adding those luscious keywords directly into the URL. What a great idea!
I decided to implement URL prettying on the blog and articles pages of the brand new Welkup.com, and everything was working great on my local box. I would click on a link with a pretty URL, a 404 error would be generated, and my designated 404 page would serve up the article. Oh yes, and it changed the HTTP status code to 200. Perfect.
I sent my files up to GoDaddy’s servers, clicked on my article, and got… a 404 error. Even though it was displaying my article, and I attempted to tell it that it had nothing to worry about, it just wasn’t cooperating. The code that worked on my local box but not on GoDaddy:
header('HTTP/1.1 200 OK');
GoDaddy support was no help but gave me the confidence I needed to continue my efforts. Needless to say, after a couple hours of Googling, I stumbled upon the following
header('Status: 200');
This DOES NOT work on my local box but miraculously solved the issue on GoDaddy. GoDaddy and I are both running v5.2 of PHP. Not really sure about this one…