Fixing broken urls using mod_rewrite

Discuss practical ways rearrange URLs using mod_rewrite.

Fixing broken urls using mod_rewrite

Postby quastdog » Fri Mar 11, 2005 2:37 pm

We recently updated a java servlet url to something totally different - something that was supposedly an internal url only. After making the change, we discovered from server logs that lots of these urls were indexed on search engines. Instead of returning a customized 404 error page when someone comes in from such SE referrals, is it possible to use mod_rewrite to return something else?

How would I turn this:
/online/store/SpecificationChart?catGroupID=4501864&storeId=8000&param=value&parm=value

into something like this (which is an existing mod_rewrite rule which resolves into an ugly url like the above example):
/category/4501864.htm

However, if storeId=8001, we want the url to be like this:
/outlet/category/4501864.htm

The catGroupID and storeId params can be in any order, any position within the QS.
quastdog
 
Posts: 1
Joined: Fri Mar 11, 2005 2:04 pm

Postby Caterham » Fri Mar 11, 2005 5:38 pm

How would I turn this:
[...]
into something like this (which is an existing mod_rewrite rule which resolves into an ugly url like the above example):


However, if storeId=8001, we want the url to be like this:
You know that you've to change the links in your html source manually :confused:


/outlet/category/4501864.htm internal rewrite to /online/store/SpecificationChart?catGroupID=4501864&storeId=8001&param=value&parm=value
Code: Select all
RewriteRule ^outlet/category/([0-9]+)\.htm$ /online/store/SpecificationChart?catGroupID=$1&storeId=8001&param=value&parm=value [L]


/category/4501864.htm internal rewrite to /online/store/SpecificationChart?catGroupID=4501864&storeId=8000&param=value&parm=value
Code: Select all
RewriteRule ^category/([0-9]+)\.htm$ /online/store/SpecificationChart?catGroupID=$1&storeId=8000&param=value&parm=value [L]
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 72 guests

cron