I want to know if we strip out file extensions using .htaccess for a new website, do we have to add rel-canonical tag for every page to avoid Google considering them as duplicate content?

To more clarify that, I mean:

I'm looking to use example.com/contact URL instead of example.com/contact.php.

The issue is, I'm worried that Google will detect these as duplicates.

example.com/contact and example.com/contact.php

Then I will be adding rel=canonical tags for every page. I want to know is this the best practice? Or what is the best way?


If you don't have a ton of backlinks:

As long as you 301 redirect or completely rewrite the URLs, Google will follow the old links and drop those. Canonicals are a good idea just to reinforce that you want to use the versions without .php extensions.

If you already have a ton of backlinks:

Don't change URLs just for the sake of changing URLs. Dropping the ".php" extension isn't really very helpful for SEO, but could be a little easier for user experience if your visitors may want to type in URLs directly occasionally. If you already have a decent amount of backlinks pointing to your site don't change the URLs - the drawbacks will outweigh the benefits and Google will keep following those old ".php" links from the other sites.

| improve this answer | |

Try removing .php using .htaccess rewrite codes via 301 redirect code. Canonicalisation is to avoid different versions of web pages.

For instance in case you have /contact and /contact-form.php and in case the /contact page is a complete contact page that also contains /contact-form.php as a part of it, the canonical version of /contact-form.php should be /contact.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.