...

View Full Version : Mod Rewrite 301 Help



cesarcesar
05-06-2011, 12:18 PM
I need to 301 some links. I have been getting my knees wet with ModRewrite for a while now, but this one seems to throw me. The format I'm looking for is below.

Old - http://www.sitename.com/big-widget/blue/2.html

New - http://www.sitename/blue-big-widgets/2.html

Two thinks to note, I have added a (s) to the end of widgets. As well as the 2.html will be any number between 1-100 depending on the page.

Thanks for your help in figuring this out.

angst
05-06-2011, 05:56 PM
try this:



redirect 301 /big-widget/blue/2.html http://www.sitename/blue-big-widgets/2.html

cesarcesar
05-06-2011, 06:53 PM
looking for a dynamic solution to work across 20,000 links

angst
05-06-2011, 07:04 PM
ah ok, give this a shot:

RewriteRule ^big-widget/blue/([A-Za-z0-9-_.]+)/?$ blue-big-widgets/$1 [R=301,L]

cesarcesar
05-06-2011, 07:13 PM
the terms "big-widget" and "blue" are a combination of of over 100 different possibilities. I'm looking for a solutions that says "take the second folder name and add it to the beginning of the first folder name, then add an (s) to the end"

m4rc3
05-09-2011, 12:37 AM
I think you are looking for something like this.

RewriteRule ^([^/\.]+)/([^/\.]+)/(.*) $2-$1/$3 [L]

cesarcesar
05-09-2011, 10:34 AM
I think you are looking for something like this.

RewriteRule ^([^/\.]+)/([^/\.]+)/(.*) $2-$1/$3 [L]

Very Close. thanks for the lead. My final usage was

RewriteRule ^(^/\.]+)/([^/\.]+)/(.*) $2-$1es/$3 [R=301,L]

m4rc3
05-09-2011, 08:12 PM
Nice !



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum