Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    144
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Mod Rewrite 301 Help

    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.

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    try this:

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

  • #3
    Regular Coder
    Join Date
    Apr 2007
    Posts
    144
    Thanks
    5
    Thanked 0 Times in 0 Posts
    looking for a dynamic solution to work across 20,000 links

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    ah ok, give this a shot:

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

  • #5
    Regular Coder
    Join Date
    Apr 2007
    Posts
    144
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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"

  • #6
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think you are looking for something like this.

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

  • #7
    Regular Coder
    Join Date
    Apr 2007
    Posts
    144
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by m4rc3 View Post
    I think you are looking for something like this.

    RewriteRule ^([^/\.]+)/([^/\.]+)/(.*) $2-$1/$3 [L]
    Very Close. thanks for the lead. My final usage was
    Code:
    RewriteRule ^(^/\.]+)/([^/\.]+)/(.*) $2-$1es/$3 [R=301,L]

  • #8
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nice !


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •