21

How do I remove the .html suffix from the product pages?

4
  • From just the product pages?
    – philwinkle
    Commented May 12, 2016 at 21:36
  • The .html suffix only seems to appear on the product pages. The CMS pages don't show .html, nor does the home page.
    – MikeMason
    Commented May 12, 2016 at 21:39
  • Categories should also show .html - would you like to remove it or change it?
    – philwinkle
    Commented May 12, 2016 at 21:39
  • Ahhh yes, you're correct, the category page has it too. I'd prefer a forward slash in its place.
    – MikeMason
    Commented May 12, 2016 at 21:40

2 Answers 2

33

Open your admin panel navigate on Stores->configuration->Catalog click on Search Engine Optimization tab

Here you can remove

Product URL Suffix =

Category URL Suffix =

enter image description here

Make these fields blank (remove .html from both fields) save the config and reindex and clear cache of your store. it's done!

11
  • Thank you for the reply. Unfortunately, when I removed the .html, I received a 404 on all product and category pages?
    – MikeMason
    Commented May 13, 2016 at 9:48
  • Did you reindex and clear cache ??
    – Arunendra
    Commented May 13, 2016 at 9:54
  • Yes, but it still shows 404 :-/
    – MikeMason
    Commented May 13, 2016 at 9:55
  • This is the right way for achieve this functionality. Delete var/generation folder retry and also see log files for any errors
    – Arunendra
    Commented May 13, 2016 at 9:58
  • Okay, thank you. Where are the log files located?
    – MikeMason
    Commented May 13, 2016 at 9:59
6

You can just remove .html suffix from your admin panel.

Go to AdminPanel,

Stores -> Configuration -> Catalog -> Catalog

Go to Search Engine Optimization Section,

Unset value for textfield inside Product URL Suffix

Same as you can do it for category url suffix below another field is Catogory Url Suffix.

If you can do any text with this field like .php then its display suffix as .php in your link.

Remove var folder and run commnad php bin/magento indexer:reindex

5
  • This works well in Magento 2.1.
    – Wireblue
    Commented Jun 9, 2017 at 0:14
  • 1
    What about the indexed content in search engines? Commented Jun 29, 2017 at 13:52
  • @FrankGroot, they no longer reference the page. It will always throw a 404. It will take time and crawlers will update the new links. How long would it take? I have no idea. Commented Jul 4, 2018 at 3:32
  • 1
    @M.Joraid And that is not the way to go, because you will lose history in the search machines. So you have to write 301 rewrite rules for those links, otherwise you will get penalized by the search engines :) Commented Jul 5, 2018 at 13:33
  • if you "Remove var folder" wouldn't that also remove .htaccess which would be bad?
    – Barry
    Commented Oct 29, 2019 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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