1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help for htaccess rule

Discussion in 'PHP & Perl' started by yazzou, Jan 5, 2011.

  1. yazzou

    yazzou Registered Member

    Joined:
    Dec 19, 2008
    Messages:
    61
    Likes Received:
    7
    Hi everyone and happy new year.
    I am trying to remove some extra useless parameters from my URLs because in google webmaster tools, they are spotted as duplicate content .
    Here is an exemple of what i see :

    Code:
    /subf/Page-15.html
    /subf/Page-15.html?change_font=large

    I would like to remove the change_font parameter. I have tried the following in my hthaccess :


    Code:
    RewriteCond %{query_string} ^.+
    RewriteRule ^(.*)$ http://www.mysite.com/$1? [R=301,L]
    However this remove some other parameters necessary for the site, so i tried the following :


    Code:
    RewriteCond %{query_string} ^.change_font
    RewriteRule ^(.*)$ http://www.mysite.com/$1? [R=301,L]

    I does not redirect....
    Would be greateful for any suggestion
    Regards
     
  2. spongecat

    spongecat Newbie

    Joined:
    Dec 18, 2009
    Messages:
    27
    Likes Received:
    2
    Use rel=canonical instead.
    In your case it would look like this

    HTML:
    <link rel="canonical" href="http://www.example.com/subf/Page-15.html" />
    Put it in head section of your code.