Need Help with httaccess or mods-rewrite Will Pay $

Discussion in 'Apache' started by gerryt, Oct 31, 2009.

  1. #1
    I will pay $10 (with Pay-Pal), for the code and instructions on redirecting all of my old "associate-o-matic" url's (from amazon) to my new wordpress site (phpbay store).
    The old urls look like this:
    [​IMG]
    ect,ect,ect...

    There seem to be thousands of them.
    I need them all to redirect to my new site's home page.
    My website is HERE
    The fix must not affect the new site and it's url's (obviously)
    Thanks
    PS: I won't necessarily pay the first person but will pay for the best solution :)
     
    Last edited: Oct 31, 2009
    gerryt, Oct 31, 2009 IP
  2. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Something like

    RewriteRule ^(buy\-)?[0-9]\-[0-9]{7}-[A-z0-9_\-]+\.html$ / [R=301,L]
    Code (markup):
    should do the trick.

    That will catch everything in the format: 1 number, -, 7 numbers, -, alphanumeric string, .html. Including those with the prefix "buy-"
     
    chadsmith, Oct 31, 2009 IP
    gerryt likes this.
  3. gerryt

    gerryt Active Member

    Messages:
    374
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thanks Chad.
    I tried the code and some of the old links still 404 on me :(
    The "buy" links work great.
    Some of the numeric links redirect fine example:
    http://olympiabeer.com/4-1036682-Fiorentina-Brand-sr-1.html
    Code (markup):
    While some of the numeric links 404 still example:
    http://olympiabeer.com/1-13218451-B001MW8P5W-Red_White_Polka_Dot_18_oz_Insulated_Mug_wMonogram_Black_Red_Emblem_Varsity_Font_Letter_U.html
    Code (markup):
    Can you figure it out?
    Thanks
     
    gerryt, Oct 31, 2009 IP
  4. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It's doing that since the second numeric part is more than 7 numbers. If you happen to know the minimum and maximum number of digits that will appear in that spot you can do something like

    RewriteRule ^(buy\-)?[0-9]\-[0-9]{7,}\-[A-z0-9_\-]+\.html$ / [R=301,L]
    Code (markup):
    To say "at least 7 digits" in that spot, or

    RewriteRule ^(buy\-)?[0-9]\-[0-9]{7,9}\-[A-z0-9_\-]+\.html$ / [R=301,L]
    Code (markup):
    for "7 to 9 digits". Otherwise you can use

    RewriteRule ^(buy\-)?[0-9]\-[0-9]+\-[A-z0-9_\-]+\.html$ / [R=301,L]
    Code (markup):
    To catch any range of numbers in the second spot.
     
    chadsmith, Oct 31, 2009 IP
  5. gerryt

    gerryt Active Member

    Messages:
    374
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Hey Chad, I used the last snippet of code you provided and it worked like a charm :D

    Please PM me your paypal info and I'll send your $10

    Well worth it :)

    Thanks again!!!!
     
    gerryt, Nov 1, 2009 IP
  6. gerryt

    gerryt Active Member

    Messages:
    374
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Hey Chad, upon further investigation, there are still a few urls that are 404'ing for some reason.
    /1-228013-Room+Decor-Brand-sr-1.html
    /1-1063498-Adam+Hersh+Posters_20000_49999-Brand_MinimumPrice_MaximumPrice-sr-1.html
    /1-1063498-Adam+Hersh+Posters_20000_49999-Brand_MinimumPrice_MaximumPrice-sr-1.html
    Code (markup):
    I'm thinking it may be the "+" signs but I have no idea on how to fix the rewrite code.
    If you could send me the fix and your email for payment I'll square up with you.
    Sorry to be a pain in the %$#
     
    gerryt, Nov 1, 2009 IP
  7. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yep, the plus signs would do it. Change it to:

    RewriteRule ^(buy\-)?[0-9]\-[0-9]+\-[A-z0-9_\ \-]+\.html$ / [R=301,L]
    Code (markup):
    To catch the URLs with spaces as well. My PayPal :)
     
    Last edited: Nov 1, 2009
    chadsmith, Nov 1, 2009 IP
  8. gerryt

    gerryt Active Member

    Messages:
    374
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #8
    Thanks Chad, you really know your stuff :D
    I have made payment via Pay-Pal
    thanks again!!
     
    gerryt, Nov 2, 2009 IP