Need Some on Help - Rewriting URL with Substitution

Discuss practical ways rearrange URLs using mod_rewrite.

Need Some on Help - Rewriting URL with Substitution

Postby jeffreycamp » Fri Jul 18, 2008 7:53 am

I think I'm close but this isn't working. I want take an address like this:

http://www.homepage.com/widget-start/homea

and rewrite it to this:

http://www.homepage.com/navigation.do?m ... e=WIDGET_A

In this example pulling "widget" and "a" from the original URL, setting them to uppercase and dropping them into the rewritten URL. In all cases "home" will appear in the request URL with either a,b,c appended to it; and the first element in the path will have the format of "[a-z]-[a-z]."

Here's the mapping I'm trying


RewriteEngine On
RewriteOptions Inherit
RewriteMap upper2lower int:tolower
RewriteMap lower2upper int:toupper


^/([a-z+])\-([a-z+])/home([abc])$ http://www.homepage.com/oo/navigation.d ... dingPage=${lower2upper:$1}_${lower2upper:$3} [R=301,L]d

Any input would be greatly appreciated.
jeffreycamp
 
Posts: 2
Joined: Fri Jul 18, 2008 7:44 am

Postby richardk » Fri Jul 18, 2008 3:12 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteMap lower2upper int:toupper

RewriteRule ^/([a-z]+)-[a-z]+/home([abc])$ /oo/navigation.do?method=DISPLAY_ALTERNATE_LANDING&alternateLandingPage=${lower2upper:$1}_${lower2upper:$2} [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby jeffreycamp » Sat Jul 19, 2008 2:47 pm

Brilliant. Thanks so much. You helped us to get something important done.
jeffreycamp
 
Posts: 2
Joined: Fri Jul 18, 2008 7:44 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 36 guests

cron