301 redirecting a query stringed URL to one without a query string

Discussion in 'Apache' started by norfstar, Jul 31, 2005.

  1. #1
    I'm tearing my hair out over this one - I imagine the answer is pretty simple but I just can't work it out.

    What I want to do is 301 redirect URLs like

    /index.php?t=view&uin=777

    to

    /777.html

    where 777 is an integer.

    Can anyone point me in the right direction?
     
    norfstar, Jul 31, 2005 IP
  2. Liminal

    Liminal Peon

    Messages:
    1,279
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Have you tried something like this?

    RewriteRule ^index.php?t=view&uin=([0-9]+)$ /$1.html [R=301,L]

    The exact syntax may very but the general idea should work, I believe
     
    Liminal, Jul 31, 2005 IP
  3. norfstar

    norfstar Peon

    Messages:
    1,154
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for you help, but yep I've tried that and it has no effect. I think it is the ? that is causing the problem. From what I've found from searches it seems that {QUERY_STRING} needs to be put in there somewhere.
     
    norfstar, Jul 31, 2005 IP
  4. Liminal

    Liminal Peon

    Messages:
    1,279
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Liminal, Jul 31, 2005 IP
  5. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #5
    RewriteCond %{QUERY_STRING} t=view
    RewriteCond %{QUERY_STRING} uin=([0-9]+)
    RewriteRule ^index.php$ %1.html? [R=302,L]
     
    J.D., Jul 31, 2005 IP
  6. norfstar

    norfstar Peon

    Messages:
    1,154
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks, but unfortunately it's not having any effect.
     
    norfstar, Jul 31, 2005 IP
  7. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Post or PM me your URL. I checked before posting - this configuration should work.

    J.D.
     
    J.D., Jul 31, 2005 IP
  8. chachi

    chachi The other Jason

    Messages:
    1,600
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Anyone have an answer to this? I am trying to figure out how to do a 301 with a url like www.domain.com/?r=5 I want to 301 that to the document root.
     
    chachi, May 2, 2006 IP
  9. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Any reason you can't just write index.php to read in the parameters and actually send the 301 header itself?
     
    TwistMyArm, May 2, 2006 IP