404 error in canonical link categories when it is two words

  • Posts: 124
  • Thank you received: 6
1 year 3 months ago #354875

-- url of the page with the problem -- : electroseyfi.ir
-- HikaShop version -- : 4.7.5

I noticed that when the category name is two-words and we put it as a canonical link, the category page gives a 404 error.

For example, I have a category called "part type", which has many subcategories. "Part type" category has a menu item, so there is no problem.

If the name of these sub-categories is one-word and I set the canonical link to "type-part/name", the link opens in Hikashop's category module without any problems. But if the name of the sub-category is two-words (for example "connector cable") and the canonical link of this category is set to "part-type/connector-cable", when I click on this sub-category in Hikashop's categories module, gives a 404 error.

In other words, categories with two-word names and no menu items will give a 404 error.

It should be noted that due to the large number of sub-categories, I don't want to make a menu for all these sub-categories.

Last edit: 1 year 3 months ago by levelup.

Please Log in or Create an account to join the conversation.

  • Posts: 83007
  • Thank you received: 13400
  • MODERATOR
1 year 3 months ago #354877

Hi,

It's because of two things:
- in each product / category, you can enter an "alias". This is the text you want to be used in the URL.
If you don't provide any, then HikaShop will use the product name as alias. But as spaces are not allowed in the URL joomla will convert them to dashes. But them HikaShop won't be able to match the alias in the URL with the product name when you click on the link, resulting in the 404 error.
So providing a proper alias without space in the product / category would prevent that problem.
- you have activated the "remove category and product ids from URLs" setting in the Hikashop configuration. This means that HikaShop can only rely on the alias in the URL to identify the product / category. If you turn off that setting, as it is by default, then regardless of the alias in the URL, HikaShop will be able to match the URL with the product / category thanks to the id of the product / category in it.

Please Log in or Create an account to join the conversation.

  • Posts: 124
  • Thank you received: 6
1 year 3 months ago #354974

nicolas wrote:
- in each product / category, you can enter an "alias". This is the text you want to be used in the URL.
If you don't provide any, then HikaShop will use the product name as alias. But as spaces are not allowed in the URL joomla will convert them to dashes. But them HikaShop won't be able to match the alias in the URL with the product name when you click on the link, resulting in the 404 error.
So providing a proper alias without space in the product / category would prevent that problem.


Aliases for categories are dashes in all two-word names, so I don't think the problem is with aliases. A screenshot of the category alias and canonical fields is shown below:



I also noticed that in order for the canonical link to work properly for these categories, I use %20 instead of dashes in the canonical field. It seems that instead of the alias field, you are using the product title field to create the page link.

Attachments:
Last edit: 1 year 3 months ago by levelup.

Please Log in or Create an account to join the conversation.

  • Posts: 83007
  • Thank you received: 13400
  • MODERATOR
1 year 3 months ago #354976

Hi,

I checked your website and the problem is indeed not with the aliases. It's what you said in your first message which led me to say this.
You said

If the name of these sub-categories is one-word and I set the canonical link to "type-part/name", the link opens in Hikashop's category module without any problems. But if the name of the sub-category is two-words (for example "connector cable") and the canonical link of this category is set to "part-type/connector-cable", when I click on this sub-category in Hikashop's categories module, gives a 404 error.

In other words, categories with two-word names and no menu items will give a 404 error.

But this has nothing to do with having two words.
For example, you have the category "key" with the URL electroseyfi.ir/part-type/key which generates the same error.
And with the new information you provided in your new message, it indeed has nothing to do with the alias.

I think the problem is elsewhere.
Either:
- you let HikaShop generate the canonical URL of your categories in the past and then you changed the settings of the SEF section of the HikaShop configuration, rendering all these URLs invalid
- you directly entered invalid URLs as canonical URLs of your categories.


Take for example the page:
demo.hikashop.com/index.php/en/hikashop/...g/display-in-div-div
It displays a listing of categories.
The first category there will have the URL:
demo.hikashop.com/index.php/en/hikashop/...iv/category/12-shoes
The "category" text there comes from the "category SEF name" setting of the HikaShop configuration.
I can see in your categories URLs that they don't have anything between the alias of the menu item and the last part of the URL with the category alias.
So the URL will only be valid if the "category SEF name" setting is empty in your HikaShop configuration.
I'm thinking you might be using something else and because of that the system tries to look for a product with the alias "key" and not for a category. That's why the 404 error says "product not found" ( محصول يافت نشد ), and not "category not found".

Please Log in or Create an account to join the conversation.

  • Posts: 124
  • Thank you received: 6
1 year 3 months ago #354984

You are right. There is nothing wrong with a alias.
The problem is that I don't want "category" to be included in my category URL.
As you can see in the figure below, in the Hikashop SEO settings, I have left the product SEO feed empty so that the word "product" is not displayed in the link of my products.


But Hikashop does not accept that the category field remains empty:
you can't have the same SEF name for product and category.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 83007
  • Thank you received: 13400
  • MODERATOR
1 year 3 months ago #355009

Hi,

Indeed. You need to fill in at least one of the two.
That's how HikaShop is able to know if your URL is for a product or a category.
If you don't want to have "category" in the URL, you can use some other text. But you need to have something.

Please Log in or Create an account to join the conversation.

Time to create page: 0.078 seconds
Powered by Kunena Forum