#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2009
    Posts
    94
    Rep Power
    6

    SEO friendly URLs. No other option than a big list of rewrites?


    Hi,

    I am using mod_rewrite to convert SEO friendly URLs into dynamic ones, eg:

    http://www.mysite.com/a-b-c.php

    becomes:

    http://www.mysite.com/productpage.php?id=1

    My concern is that I have 1000's of products to put on the site, and each SEO friendly URL can have any combination of words/numbers in it. There is no pattern or common trend throughout them.

    So, I don't think RegEx will be useful, and my current belief is that I have no other option than simply having a big flat file containing which SEO friendly URL matches the dynamic ?id= URL.

    This to me seems really inefficient and just overall bad design.

    Does anyone have any ideas or anything? Or is this simply how it's done?

    Many thanks for any input.
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    Normally your products database contains a column with the SEO friendly URL value in it (ex: 'a-b-c') and you use that to map 'a-b-c' to id=1 rather than trying to maintain a giant flatfile list.

    Since you can't perform a lookup into your custom database using mod_rewrite, what you normally do is map all URLs to your PHP code, or least all URLs that don't point to real files, and then let your PHP code figure out what to do with it from there.

    Since it's possible that your website might contain things other than products, you might want to structure your URLs like: http://www.mysite.com/product/a-b-c instead of just /a-b-c.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo