I'm using a .htaccess to create a clean URL but
when I checked my site
example.com/some-request
it has duplicate content with
xyz.com/product_view.php?category_id=some-request
I'm finding hard how to fix this and this is my rewrite rule:
RewriteEngine on
RewriteBase /
RewriteRule ^([0-9a-zA-Z_-]+)$ product_view.php?category_id=$1 [NC,L]
What can be a better solution for this?
You need to externally redirect requests for
example.com/product_view.php?category_id=some-request
to
xyz.com/some-request
before your internal rewrite.Try the following:
Bit of an aside... but it's only really duplicate if these URLs get indexed. If you have always linked to your "pretty" URL then the risk is relatively low. This can also be avoided by setting the appropriate
rel="canonical"
link
element on your pages.