Forum Moderators: phranque
Not sure if this has been asked before, but I couldn’t find any info on it.
I want to make my pages more SEO friendly, so I want to turn:
www.my-site.com/foo?c=1&id=234
to
www.my-site.com/cooking/I-like-corn-pies
That's no problem. But how could I do this for lets say 1mill pages. (Not that I have that many, but you get the idea.)
Writing one line per db entry seams like a bad idea, and it would create a huge file, so there must be some other way.
Could you guys enlighten me a bit?
Vali
Two solutions are:
1) Add the new friendly URLs to the existing database itself, and modify your script to use the new URLs on your pages and to do the redirects when needed.
-or-
2) Use mod_rewrite's RewriteMap to call a script to do a lookup in that database, or in a separate one, to redirect the old c=x&id=y URLs to the new descriptive URLs. (You must still modify your script to use the new URLs on the pages it generates, though.)
Jim
In my past life prior to my current job of using Apache/PHP I worked with ColdFusion. In ColdFusion and I assume most other web languages its possible to do something like a RewriteMap at the code level.
Ive done this for a few sites (page numbers in the 50k+ range) and were able to move this from one server to another easily, across multi servers, and had great control over the wide variety of page types(templates). Im not saying this is the best solution for you - but a possible option.
It is most useful when an internal rewrite is desired based on a client-requested URL which cannot be directly mapped to a server filepath or script invokation by a simple text-transform or rearrangement of the URL, as is the case if the requested URL is /small-green-widget and the actual path is /products.php?prodid=102347
In a case like this, the database is organized based on product ID numbers, and the script looks up the URL to be published as a link on the page for bookmark, usability, and SEO purposes. When that URL is subsequently requested from the server by a client, RewriteMap can call a script to look up the correct product id needed to call the script, using the inverse of the process used for on-page link publishing.
And as mentioned previously, if the script can be customized, then this lookup function can indeed be done within the script itself, as long as the requested URLs which should invoke the script are sufficiently unique for a simple mod_rewrite pattern to identify and forward the request to the script.
Jim