301 redirect... just can't figure it out

Discussion in 'Apache' started by cgo85, Aug 30, 2008.

  1. #1
    I need to redirect something like this:

    http://www.abcd.com/abcd/$state-$county-$city.html

    To

    http://www.abcd.com/1234/$state-$city.html

    So basically just get rid of the '$county'.

    I've tried two things...

    RedirectMatch 301 ^/apartment/(.*)-(.*)-(.*).html http://www.abcd/forrent/$1-$3.html

    This redirected me to a url (example): state-city.html?state=WA&countyurl=King&cityurl=Seattle


    AND

    <?
    $state = $_GET['state'];
    $county = $_GET['county'];
    $city = $_GET['city'];
    
    header( "HTTP/1.1 301 Moved Permanently" );
    header( "Location: http://www.rental-apt.com/$state-$city.html" );
    exit();
    ?> 
    PHP:
    This just redirected me to a 404 page


    Can anyone please shed some light on this?

    Thanks!
     
    cgo85, Aug 30, 2008 IP
  2. cgo85

    cgo85 Peon

    Messages:
    380
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't really understand what you're saying... the state, county, city are dynamic variables. It is not just one static page I'm trying to redirect. All trafffic directed to url format $state-$county-$city.html needs to be redirected to $state-$city.html
     
    cgo85, Aug 30, 2008 IP
  3. The Universes

    The Universes Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try this:
    Post length 1 2 3
     
    The Universes, Aug 30, 2008 IP