Forum Moderators: phranque

Message Too Old, No Replies

Rewrite Extracting Url Names from DB

         

southernrob

11:03 am on Apr 9, 2005 (gmt 0)

10+ Year Member



Hello there,
This looks a really useful forum.
I know nothing of Apache, but would like to master the mod rewrite.
I have a site that sells property and uses <a commercial script>. I use a rewrite mod that makes the urls a bit more friendly ie http://www.moving-to-a_particular_country.com/houses/listingview-373.html instead of showing listingview.php?id=373
Now i would like to have the urls rewritten drawing individual titles from the database, hence showing http://www.moving-to-a_particular_country.com/houses/leaseback_paris_cote_seine D373.html or even better taking the region or town from the database and making virtual directories.
How can I extract id=373 data from the db and use it in the url?
I am lost.
Best regards,
Rob Thorne

[edited by: jdMorgan at 4:00 pm (utc) on April 9, 2005]
[edit reason] Removed specifics per TOS. [/edit]

jdMorgan

4:09 pm on Apr 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Rob,

Welcome to WebmasterWorld!

The majority of changes will be made in your php code, at the point where the php script creates a link on the html "page" using data drawn from the database. This is often done with php's preg_replace directive. You then use mod_rewrite to rewrite requests for those "friendly" URLs, when requested by browsers and search engine spiders, back into the form neede to invoked ths script.

The only critical point is that the friendly URL must contain all information needed to create the internal call to the script, or the script must know how to creat a new page using only the information in the requested URL. Mod_rewrite cannot 'create' new information from nothing, so it's important to understand this point.

The mod_rewrite part is easy; Most of the work goes into modifying the script. You can ask over in our PHP Server Side Scripting forum, or post for hired help in our Commercial Exchange forum.

For more information, see the documents cited in our forum charter [webmasterworld.com], and try a site search for "rewrite friendly URL [google.com]."

Jim

southernrob

10:34 pm on Apr 10, 2005 (gmt 0)

10+ Year Member



Thank you Jim,
i shall do as you say. Never having heard of 'preg_replace' it will take me some time to digest :).............. and then I will be back with more questions!
Best,
Rob