January 14th, 2012, 02:15 PM
SEO friendly URLs. No other option than a big list of rewrites?
I am using mod_rewrite to convert SEO friendly URLs into dynamic ones, eg:
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.
January 14th, 2012, 11:37 PM
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.