cancel
Showing results for 
Search instead for 
Did you mean: 

Double .html in URL when adding new sub category

Double .html in URL when adding new sub category

Hi,

I've looked online and through the forum but can only locate topics covering when the end of the URL becomes .html.html, not the issue I have.

 

I have come to add some new categories to our site and when doing so notice that as soon as I add a sub category to any existing category, the original .html remains in the URL followed by .html at the end of the URL which is the new final level in that category.

 

Example:

 

This is a URL which we've had setup for years working fine (only 1 .html at the end):

https://urmstonaquatics.com/aquarium-department/heating/heaters/reef-one-heaters.html

 

If I add a new category at the same level, after /heaters/ there is now another .html so the URL looks like the below (2 .html in the same URL):

 

https://urmstonaquatics.com/aquarium-department/heating/heaters.html/dd-titanium-heaters-controllers.html

 

If you manually remove the first .html which makes the URL look correct the link breaks, I'm not sure how to remove this or how to stop it being added when creating new categories.

 

I can't see anything obvious causing this, I've set up other categories across the site as tests and it seems to be doing this on them add for some reason?

 

Any help would be greatly apprechiated.

 

Thanks,

Chris. 

7 REPLIES 7

Re: Double .html in URL when adding new sub category

Hi @salesurmst8ade 

 

Please follow below steps:

 

Go to Stores > Configuration > Catalog > Catalog > Search Engine Optimization > Category URL Suffix to remove . html you can change configuration and save it.

Flush cache by below command:
php bin/magento cache:flush

 

It may help you to remove .html from url.

 

Problem resolved? Please click on 'Kudos' & Accept as Solution!

Re: Double .html in URL when adding new sub category

@salesurmst8ade ,

seems like there are wrong URLs saved in Category URLs into url_rewrite table 

To correct that, you need to re-generate all Category URLs 

there are modules available from which you can do that command line 

Install following extension using composer 

 

composer require olegkoval/magento2-regenerate-url-rewrites

enable the extension

 

 

php bin/magento module:enable OlegKoval_RegenerateUrlRewrites

then regenerate the URLs 

 

 

php bin/magento ok:urlrewrites:regenerate --entity-type=category

 

 

if the issue is also with product URLs than you need to regenerate product URLs too :

php bin/magento ok:urlrewrites:regenerate --entity-type=product

 

Note: the command may take time depending on your catalog size. 

 

kindly Accept as a Solution if this works for you and give Kudos Smiley Happy 

 

Re: Double .html in URL when adding new sub category

@amitsamsukha  I will check this and get back to you.

 

I have since created more products and categories and it seems to be doing it on everything, even if I install this and re-generate URL rewrites, will they need to be regenerated everytime something new is created?

 

Do you know how any way to amend this issue at the root cause?

 

Kind Regards,

Chris. 

Re: Double .html in URL when adding new sub category

@Bhanu Periwal 

Hi, thanks for the help. Unfortunately this didn't work, although it removed the .html from the end the .html was still embedded in the nav link - If I remove it the category wouldn't load.

 

I assume this is down to URL rewrites being wrong too.

 

Thanks.

Re: Double .html in URL when adding new sub category

@salesurmst8ade 

This is a one-time process you just need to do it once. 

you do not need to regenerate via this module every time you create any category. 

 

this module helps to delete & regenerate all URLs. 

 

RE : root cause of this issue :
I am also figuring this but this issue is resolved once URLs are re-generated 

so it must be due to the url_rewrite table messed up. 

 

Re: Double .html in URL when adding new sub category

The problem still persists.in spite of installing olegkoval. 

Re: Double .html in URL when adding new sub category

we are having the same issue. Has anyone resolved the problem?