Clean URLs Are All the Rage

July 8th, 2005 | by Mike |

I know what you are thinking! “The permalink on this post has an ugly extension on it! ‘.php’? What the hell is that? Get with the times man!” Yes, I know clean URLs are one of the cool hip new steps to becoming part of the “Web 2.0” movement. Well I finally decided into looking into cleaning up my URLs, the problem is, I don’t want to do the work. Do you want to dig ourself out of a self-created extension mess? Here are some links to help:

The first link is a great tutorial on the way this all works and how you can do it yourself via PHP [ Making “clean” URLs with Apache and PHP ]

This is just a .htaccess file that someone wrote up that will take a passed, clean, URL and show the user a .php that has the information they’re looking for. This a nice way to go if you don’t want to actually change your URLs around. [ Neat Tip for Clean URLs ]

Ok, great huh? Clear as mud right? Well I would like to implement my whole site with clean URLs, not just my media page. I think I have a plan or two, but neither sound fun. Are there any users of MovableType out there that have made this switch? Any suggestions to save my self some time? I don’t exactly use a stock setup of MT, but I’ll take any ideas that come this way. Hell even if you aren’t using MT I would love to hear what a huge pain in the ass this is to syke myself up.

  1. 4 Responses to “Clean URLs Are All the Rage”

  2. By danielcole on Jul 8, 2005 | Reply

    I switched mt.net over to clean urls a few months ago (away from .php’s). I was having trouble getting my reg. expression correct in the .htaccess until I realized that it’s easier to just pass the entire url argument string to index.php and parse it there.

    Now the whole site is database driven and adding a new ‘page’ is just adding a new entry into a mysql table. I can specify page title, icon, and if it’s a public or password-protected page.

    There was a problem with having the .htaccess in the root folder and bleeding into other areas of the webserver (test sites, internal stuff, etc). Putting a one-line .htaccess with ‘RewriteEngine off’ turns it off for all url requests for that subfolder and below.

    Also realize that a lot of places link to specific pages on your site (random blogs, Google). If you drop the .php extension entirely your 404 Error page will explode. For a while you have to make sure to write your redirect expressions to account for both types of requests. I don’t know how MT organizes files at all, so this may or may not be a problem. On my homegrown site it was a biggie.

  3. By danielcole on Jul 8, 2005 | Reply

    I switched mt.net over to clean urls a few months ago (away from .php’s). I was having trouble getting my reg. expression correct in the .htaccess until I realized that it’s easier to just pass the entire url argument string to index.php and parse it there.

    Now the whole site is database driven and adding a new ‘page’ is just adding a new entry into a mysql table. I can specify page title, icon, and if it’s a public or password-protected page.

    There was a problem with having the .htaccess in the root folder and bleeding into other areas of the webserver (test sites, internal stuff, etc). Putting a one-line .htaccess with ‘RewriteEngine off’ turns it off for all url requests for that subfolder and below.

    Also realize that a lot of places link to specific pages on your site (random blogs, Google). If you drop the .php extension entirely your 404 Error page will explode. For a while you have to make sure to write your redirect expressions to account for both types of requests. I don’t know how MT organizes files at all, so this may or may not be a problem. On my homegrown site it was a biggie.

  4. By Mike on Jul 10, 2005 | Reply

    Ok, its done. No more extensions. I used this apache rule:

    RedirectMatch permanent /archives/(.*).html$ http://hellyeahbitch.com/archives/$1

    …and rebuilt every thing. Now if you go to a page with .php, you are redirected to the one with no extension. No linking problems!

    [ Moving on]
    I made a few sites that are basically databases with one php file on the end, but for this site, I like having MT generate the static pages instead of doing everything dynamically. That is actually the main reason that I haven’t moved to wordpress or something like that.

  5. By Anonymous on Jan 12, 2012 | Reply

    fine

Sorry, comments for this entry are closed at this time.