Problem directing old dynamic urls to new static ones

Discussion in 'Apache' started by benson712, Dec 14, 2006.

  1. #1
    I recently changed my site so that it now uses static urls as opposed to dynamic ones. I've been trying to figure out a way within .htaccess to direct the old dynamic urls to the new static ones. The problem I have is that there really is no pattern that corresponds the old to the new so I don't think I can use a mod_rewrite. I'm trying to use just a standard 301 redirect but I can't figure out how to do it with dynamic urls. Here's an example of the urls:

    old: http://www.mysite.com/productpage.php?productid=1&productname=widget1&catname=bluewidgets

    new: http://www.mysite.com/my-widgets-page.php

    Anyone have any ideas?
     
    benson712, Dec 14, 2006 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    If productpage.php doesn't actually exist, you could use

    
    <?
    switch($_GET['productid'])
    {
    case 1 :
    header("location: http://www.location.of.product1.php");
    break;
    
    case 2:
    header("location: http://www.location.of.product2.php");
    break;
    }
    ?>
    
    PHP:
    Does that page exist ?
     
    krakjoe, Dec 14, 2006 IP
  3. benson712

    benson712 Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't currently have the page up but I can add it back to the site. The code you included would be added to productpage.php correct? I would basically have a different case statement for each new url?
     
    benson712, Dec 14, 2006 IP
  4. benson712

    benson712 Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    This worked like a charm krakjoe. Thanks so much!
     
    benson712, Dec 14, 2006 IP