Surf Roots, Software Thoughts

A blog by Alex Loddengaard

PHP Pretty URLs

I’ve always wondered how to handle pretty URLs in PHP. Read the whole article, but in summary, you setup an Apache Rewrite:

sh: /usr/bin/states: No such file or directory

And setup your index.php file with the following framework:

sh: /usr/bin/states: No such file or directory

Turns out pretty URLs in PHP are super easy, and they’re great for SEO.

Update: You need to be a little more careful will 404 handling. Your 404.php page must have the following line at the top of it:

sh: /usr/bin/states: No such file or directory

If you don’t do this, then search engines who come across your “404″ page will get a status message of 200, indicating that the page loaded just find. This means that they’ll add this page to their index and also not remove any pages already in their index that no longer exist.

2 Comments so far

  1. [...] domain is pretty unbelievable, I wanted to make the entire site as SEO driven as possible. I have pretty URLs, and keyworded titles and headers. Kyle and I are hoping to get tons of organic search traffic, and [...]

  2. [...] Seattle Bars a few months back, I had worked only shortly on a pseudo PHP controller to support keyword-rich, pretty URLs. The controller also handled the case when a page wasn’t found. In this case, the controller [...]

Leave a reply