0

Depending on google suggestions, I tried to add some codes to my .htaccess to prevent duplicate content. This is my code:

#Duplicate Content
RewriteCond %{HTTP_HOST} !^www.soomar63.com$ [NC]
RewriteRule ^(.*)$ http://www.soomar63.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ 
RewriteRule ^index\.php$ http://www.soomar63.com/ [R=301,L]
#Remove Trailing Slash
RewriteCond %{HTTP_HOST} ^(www.)?soomar63\.com$ [NC]
RewriteCond %{THE_REQUEST} !administrator/(.*)$
RewriteRule ^(.*)/$ http://www.soomar63.com/$1 [R=301,L]

This code is working fine, it have just a little problem:

This code corrects following links:

soomar63.com -> www.soomar63.com
soomar63.com/ -> www.soomar63.com
soomar63.com/index.php/ -> www.soomar63.com
soomar63.com/about.html/ -> www.soomar63.com/about.html

But it dosen't corrects following links:

soomar63.com/index.php?mylink/ -> must correct to www.soomar63.com/index.php?mylink
soomar63.com/about.html#mylink/ -> must correct to www.soomar63.com/about.html#mylink

Please help. Thank you.

Amir
  • 45
  • 4

1 Answers1

0

Replace your #Remove Trailing Slash rules with below

#Remove Trailing Slash

RewriteCond %{HTTP_HOST} ^(www.)?soomar63\.com$ [NC]
RewriteCond %{THE_REQUEST} !^/?administrator$
RewriteRule ^ http://www.soomar63.com%{REQUEST_URI} [R=301,L,QSA]
Rahil Wazir
  • 10,007
  • 11
  • 42
  • 64
  • Thank you for your replay, but it didn't solve my problem, this code creates infinite loop in my site and give the error page... – Amir Apr 01 '14 at 13:14