Skip to content

A lazy web request about Apache rewrite rules

I’ve finally gotten around to porting my old Radio archives over to WordPress. One unintended consequence is that the urls for the individual daily archive entries change. In Radio the archive entry for today would be http://www.mcgeesmusings.net/2007/05/14.html; In WordPress the URL becomes http://www.mcgeesmusings.net/2007/05/14 .

Google searches that point to an old Radio URL end up with a 404 not found error. This seems to be a case where Apache’s rewrite rules should help, but I don’t know how to write the right rule off the top of my head. I could do my usual combination of searching for clues and trial and error. Perhaps someone out there could point me in a productive direction in the comments.

{ 4 } Comments

  1. Grig Gheorghiu | May 14, 2007 at 4:22 pm | Permalink

    RewriteEngine On
    RewriteRule /(\d\d\d\d\/\d\d/\/\d\d)\.html /$1

    Very simplistic, but should do the trick for URLs of the form you mentioned.

    If you just want to get rid of .html at the end, you can use:

    RewriteRule /(.*).html /$1

    Grig

  2. Jim | May 14, 2007 at 4:34 pm | Permalink

    thanks for the quick idea - I will try it out tonight or tomorrow - depending on my schedule

  3. Grig Gheorghiu | May 18, 2007 at 5:05 pm | Permalink

    Any luck with those rules? Just curious….

    Grig

  4. Jim | May 29, 2007 at 12:46 pm | Permalink

    haven’t managed to get it to work yet, but I’ve had little time to do any debugging either

Post a Comment

Your email is never published nor shared. Required fields are marked *