.htaccess redirectperminant not working

Discussion in 'Apache' started by lonewolfonline, Feb 3, 2008.

  1. #1
    Hi,

    I'm trying to redirect a bunch old urls to a newer and better url using RedirectPermanent, but for one subset its just not working!...

    Rules such as

    RedirectPermanent /contact.php http://lonewolf-online.net/contact/
    Code (markup):
    work exactly fine, however if they have a '?' in them it just refuses to work. I also tried RedirectMatch but still get a 404.

    RedirectPermanent /doarticle.php?article=computer_howto_hpze5400 http://lonewolf-online.net/computers/tutorial/hp_pavilion_ze5400_dismantle/
    
    Code (markup):
    and
    RedirectMatch ^/doarticle.php/\?article=computer_howto_hpze5400$ http://lonewolf-online.net/computers/tutorial/hp_pavilion_ze5400_dismantle/
    
    Code (markup):
    and some of the existing inbound links contain a forward slash before the ?:

    RedirectPermanent /doarticle.php/?article=computer_howto_hpze5400 http://lonewolf-online.net/computers/tutorial/hp_pavilion_ze5400_dismantle/
    Code (markup):
    How do I get these to redirect?? I have about 2 dozen different article= urls. Its been driving me crazy.

    Thanks
     
    lonewolfonline, Feb 3, 2008 IP
  2. Dr. XYZ

    Dr. XYZ Guest

    Messages:
    226
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try using mod_rewrite instead.
     
    Dr. XYZ, Feb 3, 2008 IP
  3. lonewolfonline

    lonewolfonline Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks,

    I tried using

    RewriteCond %{REQUEST_URI} doarticle.php/\?article=computer_howto_hpze5400 [NC,OR]
    RewriteRule ^(.*) http://lonewolf-online.net/computers/tutorial/hp_pavilion_ze5400_dismantle/ [R=301,L] 
    Code (markup):
    which redirects to

    http://lonewolf-online.net/computers/tutorial/hp_pavilion_ze5400_dismantle/?article=computer_howto_hpze5400
    Code (markup):
    but how do I remove the ?article=computer_howto_hpze5400 from the URL? I am now getting a

    Thanks
     
    lonewolfonline, Feb 3, 2008 IP
  4. lonewolfonline

    lonewolfonline Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi,

    I'm still having problems with this. I have been playing around with various combinations of the above as well as this:

    RewriteCond %{QUERY_STRING} ^article=computer_howto_hpze5400
    RewriteRule /* http://lonewolf-online.net/computers/tutorial/hp_pavilion_ze5400_dismantle/ [R,L]
    Code (markup):
    But either the rule does not pick up or it gets stuck in a infinite loop.

    The value of article in the query string will never be the same as the new url. doarticle.php has not existed on the site for a few years and never will.

    There must be a way of redirecting a url containing a query string...

    Anybody able to help?

    Thanks

    lonewolf
     
    lonewolfonline, Feb 5, 2008 IP
  5. sumeetindia

    sumeetindia Banned

    Messages:
    409
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If you just need to redirect to the new url then try this

     
    sumeetindia, Feb 5, 2008 IP
  6. lonewolfonline

    lonewolfonline Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The url has not changed. I removed doarticle.php in favour of a new cleaner structure. I don't need anything fancy or dynamic, just a google friendly redirect of
    http://lonewolf-online.net/doarticle.php?article=computer_howto_hpze5400
    to
    http://lonewolf-online.net/computers/tutorial/hp_pavilion_ze5400_dismantle/

    I have many more pages and articles that will be redirected in the same way. I was hoping just a simple RedirectPermanent (as first post) would suffice.

    Thanks anyway,

    lonewolf
     
    lonewolfonline, Feb 5, 2008 IP