Rewriting URL without losing page rank - Help Please !

Discussion in 'Apache' started by web_junkie, Feb 6, 2009.

  1. #1
    Hi, I want to rewrite a URL from one of may pages, but also want to redirect all traffic from the old URL to the new change one, example:

    Old URL : www.mysite.com/results.php?category=5
    New URL : www.mysite.com/alpaca-rugs

    For this to work, I have place the following code in my. htaccess page :

    RewriteRule ^alpaca\-rugs$ results.php?category=5

    which works fine by it self , but since I know that only the old URl appears on the SERPs I have to redirect all traffic going to the old URL to the new one, so for this second task, I have added the following code:

    RewriteCond %{QUERY_STRING} ^category=5$
    RewriteRule ^results.php$ /alpaca-rugs

    But it does not redirect properly. I'm not an expert on this subject so please can someone help fix this problem.

    Thanx
     
    web_junkie, Feb 6, 2009 IP
  2. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #2
    replace RewriteRule ^results.php$ /alpaca-rugs with RewriteRule ^results.php$ /alpaca-rugs [R=301,L]
     
    buldozerceto, Feb 6, 2009 IP
  3. Sparaker

    Sparaker Peon

    Messages:
    204
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    try this:

    RewriteCond %{QUERY_STRING} ^category=5$
    RewriteRule ^results.php /alpaca\-rugs [L, R=301]

    this needs to be above your other lines in htaccess.

    Let me know if it works.
     
    Sparaker, Feb 6, 2009 IP
  4. web_junkie

    web_junkie Active Member

    Messages:
    98
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #4
    Hi, thanks for the reply, ok, I tried both but it does not redirect properly and I get the following URL on the browser address bar:

    http://www.mysite.com/alpaca-rugs?category=5

    I also tried :

    RewriteCond %{QUERY_STRING} ^category=5$
    RewriteRule ^results.php$ /alpaca-rugs? [L,R=301]
    RewriteRule ^alpaca\-rugs$ results.php?category=5

    It does not redirect properly either but I get http://www.mysite.com/alpaca-rugs
    on the browser address bar , any more suggestions?

    Thanks
     
    web_junkie, Feb 6, 2009 IP
  5. darrenbeige

    darrenbeige Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Try this code aswell as the code that is currently working

    RewriteRule ^alpaca\-rugs$ results.php?category=5 [R=301]

    But, even if you do get it going, I think its a given that you will suffer temporary PageRank drop anyway, regardless of whether you redirect as well. But don't panic, it should return to normal eventually.
     
    darrenbeige, Feb 8, 2009 IP
  6. websecrets

    websecrets Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You do realize that no matter how you do this you will potentially change your PR or search rankings right? Just something to consider before you do anything crazy. :p
     
    websecrets, Feb 17, 2009 IP
  7. mateon3000

    mateon3000 Peon

    Messages:
    31
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I agree with websecrets. You should be careful before you permanently change your url. Unfortunately I dont have an answer and Im not too sure how fast someone from google would help you transition your pages without losing your search rankings. Have you tried searching httpdot//wwwdotapacheforumdotcom. Im sure this has come up before.
     
    mateon3000, Mar 3, 2009 IP