Forum Moderators: phranque

Message Too Old, No Replies

SEO url rewrite

rewrite to a friendly web address

         

dclawson

10:50 pm on Dec 28, 2008 (gmt 0)

10+ Year Member



Hi all,

I'm developing an e-commerce application that consists of a number of product categories each with a number of products assigned.

A sample web address currently looks like:

[mysite.com...]

I want to use .htaccess and mod_rewrite to rewrite this URL to a more SEO friendly:

[mysite.com...]

Can somebody please guide me as to how i can get the url rewriting like so?

thanks!

g1smd

1:30 am on Dec 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This question comes up several times per week.

You'll need to rewrite the request to an internal PHP (or similar) script that looks up in the database which record is the right one matching that title.

There's several dozen very detailed answers over the last few months here.

dclawson

10:09 am on Dec 29, 2008 (gmt 0)

10+ Year Member



thanks for the reply & advice.

Ill search through some past posts and see if i can figure this out.

jdMorgan

4:42 pm on Dec 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The main point is that mod_rewrite does not have access to the information needed to "map" /mobile-phones/nokia to /products.php?id=3 -- That is, it doesn't know that "mobile-phones/nokia" and the "id=3" in "products.php?id=3" are associated.

So, you will need to rewrite any "mobile-phones" URLs to your products.php script (or to a script) which can establish the association by accessing your database.

Generally, the easiest way to do this is to simply add this function to your existing script. However, if it's an off-the-shelf script that you cannot modify, or if doing so would mean recurring modifications every time a new version of the script is released, then a good solution is to call your own "wrapper" script which does this "association lookup" function, and then #includes the off-the-shelf script.

Jim

[edited by: jdMorgan at 4:56 pm (utc) on Dec. 29, 2008]