- Code: Select all
http://mysite.com/classic/us/ga/atl/0/abc.shtml
to
- Code: Select all
http://mysite.com/US/Georgia/Atlanta/Dining/10_Degrees_South
Since there are several hundred files per city code (based on listing type -- i.e. dining, shopping, entertainment, etc), is it possible to have Apache/mod_rewrite do something convert the old URL path (on-the-fly) to the new SEO layout sort of like how 'awk' works?
File structure: /web/mysite.com/htdocs/classic/us/ga/atl/0/abc.shtml
$1 = web
$2 = mysite.com
$3 = htdocs
$4 = classic
$5 = us
$6 = ga
$7 = atl
$8 = 0
$9 = abc.shtml
Variables that are needed...
$5 -- Country Code
$6 -- State Code
$7 -- City Code
$8 -- Listing Type
$9 -- Business Listing Webpage
---
I was thinking I could use the RewriteMap Directive for the full name of the County, State and City codes when identified from the old URL listing and rewrite the URL that way, but it gets a bit confusing...
Original URL: http://mysite.com/classic/us/ga/atl/0/abc.shtml
SEO County Map file: /web/mysite.com/htdocs/seo_country.txt
- Code: Select all
us US/
cn Canada/
SEO State Map file: /web/mysite.com/htdocs/seo_state.txt
- Code: Select all
al Alabama/
ga Georgia/
SEO City Map file: /web/mysite.com/htdocs/seo_city.txt
- Code: Select all
atl Atlanta/
sav Savannah/
SEO Listing Map file: /web/mysite.com/htdocs/seo_listing.txt
- Code: Select all
0 Dining/
1 Shopping/
2 Entertainment/
3 Museums/
4 Navigate/
SEO Location Map file: /web/mysite.com/htdocs/seo_location.txt
- Code: Select all
abc.shtml 10_Degrees_South/
def.shtml Steaks-R-Us/
Actual mod_rewrite code
- Code: Select all
RewriteEngine On
RewriteMap country txt:/web/mysite.com/htdocs/seo_country.txt
RewriteMap state txt:/web/mysite.com/htdocs/seo_state.txt
RewriteMap city txt:/web/mysite.com/htdocs/seo_city.txt
RewriteMap listing txt:/web/mysite.com/htdocs/seo_listing.txt
RewriteMap location txt:/web/mysite.com/htdocs/seo_location.txt
RewriteRule ^/classic/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?(.*) ${country:$1}/{state:$2}/{city:$3}/{listing:$4}/{location:$5} [redirect=permanent,last]
---
The end run solution would be that the URL to show up as the SEO URL when seen in a browser rather than the drawn out 'old' URL path.
Old URL: http://mysite.com/classic/us/ga/atl/0/abc.shtml
SEO URL: http://mysite.com/US/Georgia/Atlanta/Di ... rees_South
-- Michael