cbeaudry1
asked on
mod_rewrite using corresponding database values
I know the basics of doing mod rewrites but am wondering how the following would be accomplished. let's say we have this URL:
http://www.website.com/productdisplay.php?category=1&product=654&color=4
I know how to get it to rewrite to www.website.com/1/654/4.html but that doesn't do squat for SEO purposes. The corresponding values to the numerals have to be inserted based on database values so that www.website.com/widgets/nose_trimmer/blue.html is actually displayed. And, BTW, it is a MS SQL database since we're running Apache2.2.2/PHP5.1.4 on a W2K server (don't ask....)
So the mod rewrites have to check what "1", "654" and "4" represent befor the URL can actually be rewritten. Can that be done from the .htaccess file?
http://www.website.com/productdisplay.php?category=1&product=654&color=4
I know how to get it to rewrite to www.website.com/1/654/4.html but that doesn't do squat for SEO purposes. The corresponding values to the numerals have to be inserted based on database values so that www.website.com/widgets/nose_trimmer/blue.html is actually displayed. And, BTW, it is a MS SQL database since we're running Apache2.2.2/PHP5.1.4 on a W2K server (don't ask....)
So the mod rewrites have to check what "1", "654" and "4" represent befor the URL can actually be rewritten. Can that be done from the .htaccess file?
Oh sorry just read the question again.
Im not aware of anyway of getting .htaccess to check a Database maybe an extemply hacky MS SQL Apache Module (if one has been written) could you not rewrite http://www.website.com/widgets/nose_trimmer/blue.html to http://www.website.com/productdisplay.php?category=widgets&product=nose_trimmer&color=blue then get the corrosponding PHP script to look up the values (not effcient I know)
Im not aware of anyway of getting .htaccess to check a Database maybe an extemply hacky MS SQL Apache Module (if one has been written) could you not rewrite http://www.website.com/widgets/nose_trimmer/blue.html to http://www.website.com/productdisplay.php?category=widgets&product=nose_trimmer&color=blue then get the corrosponding PHP script to look up the values (not effcient I know)
ASKER
I know the rewrite rule parameters your had in your first answer. Doing rewrites based on the second answer wouldn't work because we'd have to add a new rule everytime a product or category or color is added. Doesn't make sense...
Unless there's a way to do it, a major rewrite of the shopping cart's navigation is the only way I see out of this dilemna.
Unless there's a way to do it, a major rewrite of the shopping cart's navigation is the only way I see out of this dilemna.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I still don't have a workable solution for this. As an example, you can see how story URLs are displayed on CNN. I'm sure that the actual directory structure of the site is not what you see in those URLs. They are undoubtedly pulling URLs that use numerical record numbers and using a rewrite to achieve the URLs you see. I need something similar.
Example:
http://www.cnn.com/2006/WORLD/meast/07/27/zawahiri.tape/index.html
Example:
http://www.cnn.com/2006/WORLD/meast/07/27/zawahiri.tape/index.html
ASKER
Bueller? Bueller?
There's gotta be a way of doing this, no?
There's gotta be a way of doing this, no?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^\.]*)\