using htaccess to avoid duplicate content

CLOSED

using htaccess to avoid duplicate content

Postby jancek » Thu Feb 11, 2010 8:01 am

Hello,

I have problem with duplicate content on my web. I would like to solve it with htaccess.

So, I have
www.domain.com/new.php?id=6
www.domain.com/new.php?id=006
with the same content. I would like to redirect first URL to second URL with 301 status code.

Also for
www.domain.com/new.php?id=36
www.domain.com/new.php?id=036

Is this possible to do automatically, through some conditions in htacess?
jancek
 
Posts: 2
Joined: Thu Feb 11, 2010 7:59 am

I got it

Postby jancek » Thu Feb 11, 2010 11:10 am

I have it, jdMorgan helped me here: http://www.webmasterworld.com/apache/4077478.htm

I would suggest that you forgo the use of mod_rewrite if this example is unclear to you; It is dangerous to copy-and-paste code into your server configuration that you do not fully understand.

RewriteCond 00>%{QUERY_STRING} ^(00)>id=([0-9])$ [OR]
RewriteCond 0>%{QUERY_STRING} ^(0)>id=([0-9]{2})$
RewriteRule ^new\.php$ http://www.example.com/new.php?id=%1%2 [R=301,L]

Note that this code will not work if additional query string parameters precede or follow "id=" -- It will need to be made quite a bit more complex to handle that situation.

Jim
jancek
 
Posts: 2
Joined: Thu Feb 11, 2010 7:59 am


Return to New Threads/Problems

Who is online

Users browsing this forum: No registered users and 4 guests

cron