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?
jdMorgan
1:12 pm on Feb 10, 2010 (gmt 0)
Yes. After reviewing the mod_rewrite documentation and the other resources cited in our Apache Forum Charter, and the example threads in our Apache Forum Library, please post your best-effort code as a basis for discussion.
Links to these resources are at the top of this page.
In general, use a RewriteCond examining %{QUERY_STRING}, and back-referencing the query in your RewriteRule after stripping it of leading zeroes.
Thanks, Jim
jancek
4:01 pm on Feb 11, 2010 (gmt 0)
I am really trying to find some similar problem here on the forum or on the internet, but without success until now. Can you please at least navigate me to some similar threads?
jdMorgan
6:39 pm on Feb 11, 2010 (gmt 0)
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.
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
7:11 pm on Feb 11, 2010 (gmt 0)
Thank you very much jdMorgan, you really helped me. It works like a charm. And whoo, I understand it :)