site Search:


 
    All Forums Hot Topics Gallery






how-to block ads


 
Search Topic:
Uniqs:
472
Share Topic
Posting?
Post a:
Post a:
Links: ·How To Get Noticed ·Web Monks FAQ ·Webhosting FAQ ·Posting Code ·How To Post ·Webhosting forum
AuthorAll Replies


Nordy

join:2007-10-20

URL Rewriting - Names to numbers (Apache)

Is it possible to do a URL rewrite where a url like »www.myurl.com/usa/california/sanjose redirects to »www.myurl.com/c=1&st=3&area=14

The problem here is, all this time we've used urls like »www.myurl.com/c=1&st=3&area=14 All areas states and countries are represented by numbers in the database. So in the above example if usa/california/sanjose redirects to c=1&st=3&area=14, if a user typed usa/florida/tallahassee he'll have to be redirected to c=1&st=5&area=3. The numbers change depending on the country, state and city.

Can URL Rewriting change names to numbers automatically depending on the name, or will we have to update the database and change all numbers to names so that the php file can draw data based on names instead of numbers.


cdru
Go Colts
Premium,MVM
join:2003-05-14
Fort Wayne, IN
kudos:7

said by Nordy:

Can URL Rewriting change names to numbers automatically depending on the name, or will we have to update the database and change all numbers to names so that the php file can draw data based on names instead of numbers.

You're going to have to have some type of a cross reference table somewhere. While you might be able to have rewrite rules that accomplish that, your rules would become very hard to maintain.

You could change your database schema so that it uses the city name instead of a number, but that's not necessary. I would suggest that you add a new table that has the country/state/city combination that cross references to the correct number(s) of the database record(s). Then just join that table into the query (presuming SQL-like database)


tao
Frazzlebats
Premium
join:2000-12-03
Lansing, MI

reply to Nordy
You risk offending google with what you seek. Tread carefully.

Perhaps you could use some PHP to parse the url and remove everything between www.myurl.com/..and../sanjose and have the url be www.myurl.com/sanjose.php. That will make google very happy and your users will know where they are all the time.



cdru
Go Colts
Premium,MVM
join:2003-05-14
Fort Wayne, IN
kudos:7

said by tao:

You risk offending google with what you seek. Tread carefully.

Nordy used the term to redirect, but using mod_rewrite you aren't actually redirecting. You are intercepting the incoming request, modifying the requested URL so that whatever is going to handle the page request gets a modified URL.

The basic idea of what he is wanting to do is done extremely often, particularly but not limited to ecommerce sites or other sites with strong organization and cookie cutter templated pages.

If he was actually redirecting pages, yes you would offend the Google gods. But done properly Google would never see the URL rewriting.


Nordy

join:2007-10-20

reply to Nordy
In the end, we decided to update the db with country, city and area names corresponding to their numbers (by adding new columns). Then we did an htaccess file with a few rules we found online. Everything seems to be working fine for now. Lets see how thing go . Thanks to all who replied


Saturday, 25-May 20:13:47 Terms of Use & Privacy | feedback | contact | Hosting by nac.net - DSL,Hosting & Co-lo
over 13.5 years online © 1999-2013 dslreports.com.
Most commented news this week
Hot Topics