Jump to content
thirty bees forum

Ideas how to change categories of products without messing up URLs


Recommended Posts

Posted

We'd like to revamp our category structure. However, product URLs are in part based on the "current" category the product is in.

I'm wondering how to change the category structure without losing the URL.

Theoretically, I see two options:

  1. Somehow freeze current URLs for products. Is there a way to do this? To me it's surprising that something as important as a product URL is automatically "dynamic" in a sense that changing a category will affect the product URL.
  2. Create rewrites for the htaccess file, either manually or using a module like: https://addons.prestashop.com/en/url-redirects/21856-url-redirect-manage-301-302-303-redirects-404-urls.html or https://addons.prestashop.com/en/url-redirects/21428-redirections-manager-manage-301-302-and-404-urls.html

If you have any other ideas/comments, by all means!

Posted

Just put the new one. And then redirect from old one. And in future try to make product URL where category is not present or is numeric. So product name is in letters but other can be numbers. If all product names are unique then there isn't any reason to use category in product URL. Usually it takes many months when bots and crawlers adapt changes. Some stupid bot will "bomb" your site forever with old URL's. Then You can use statsmodule which collect bad request.

  • Thanks 1
Posted

This can be also bad. At the moment browsers can remember almost anything. So when customer can't remember product name, then URL will help if tipping this name. With random numbers only in URL there is no way.

Posted
9 hours ago, led24ee said:

This can be also bad. At the moment browsers can remember almost anything. So when customer can't remember product name, then URL will help if tipping this name. With random numbers only in URL there is no way.

Good point. But the typing search typically also turns up the meta data, so page name. Will think about name vs ID, though.

Posted

This functionality is kinda weird.

If you have product ID in your url schema, for example {categories:/}{id}-{rewrite}, then system will use the product id directly and it doesn't matter what is entered in categories portion of path (even product rewrite can be wrong, it is not checked) 

For example url

 https://domain.com/en/a/b/c/d/2-whatever

will automatically redirect to url of product with id 2 - for example

 https://domain.com/en/gifts/2-soap

However, if you don't have ID in your url schema - for example {categories:/}{rewrite} then system will try to resolve the product ID by 

  1. looking into db if product with given rewrite exists
  2. if it exists, then check that url matches

The step #2 seems to be unnecessary, and is causing troubles. Without it, the system would automatically perform redirect for url for product with matching rewrite

 https://domain.com/en/a/b/c/d/soap

but now it returns page not found, because the url for soap does not match expected url

 https://domain.com/en/gifts/soap

I will probably fix this in bleeding edge / 1.5

@30knees with this change, you shouldn't have to do anything. Your old urls will be automatically redirected to new ones.

  • Like 2
Posted
2 hours ago, datakick said:

@30knees with this change, you shouldn't have to do anything. Your old urls will be automatically redirected to new ones.

Does this mean that with your fix we can change categories and product URLs and the rewrite will always redirect to the product with that ID? That would be amazing!

Posted
21 hours ago, 30knees said:

Does this mean that with your fix we can change categories and product URLs and the rewrite will always redirect to the product with that ID? That would be amazing!

Yes, as long as the schema remains the same - for example {categories:/}{rewrite}

If you change the schema, then the old urls will stop working.

  • Like 1
  • 2 months later...
  • 3 weeks later...
Posted (edited)
On 7/16/2023 at 2:02 AM, datakick said:

This functionality is kinda weird.

If you have product ID in your url schema, for example {categories:/}{id}-{rewrite}, then system will use the product id directly and it doesn't matter what is entered in categories portion of path (even product rewrite can be wrong, it is not checked) 

For example url

 https://domain.com/en/a/b/c/d/2-whatever

will automatically redirect to url of product with id 2 - for example

 https://domain.com/en/gifts/2-soap

However, if you don't have ID in your url schema - for example {categories:/}{rewrite} then system will try to resolve the product ID by 

  1. looking into db if product with given rewrite exists
  2. if it exists, then check that url matches

The step #2 seems to be unnecessary, and is causing troubles. Without it, the system would automatically perform redirect for url for product with matching rewrite

 https://domain.com/en/a/b/c/d/soap

but now it returns page not found, because the url for soap does not match expected url

 https://domain.com/en/gifts/soap

I will probably fix this in bleeding edge / 1.5

@30knees with this change, you shouldn't have to do anything. Your old urls will be automatically redirected to new ones.

Removing the ID was something in the old Prestashop world called "Pretty URLs" IIRC... and a lot of people were absolutely adamant that it was necessary for google rankings. Well I have top slot in quite a few google results that I want to rank in, with highly sought after rankings for those I haven't focused on - usually better than the manufacturers of the products I carry. But more importantly, in the last 10 years of using prestashop, now thirty bees, having that product ID in my urls has saved my bacon on a number of occasions because it provides an anchor point for a product, regardless of whether the purpose is searching, linking, or entering new products. Yep, one of the issues I ran into was an ever increasing number of "collisions" that caused noticeable slowdown of the site as well as an increase in 404 page errors (mostly misses from older links) in the logs. I presume this happened because I have a large catalog (17,000+ items) with a substantial number of "visits" (over 500,000/mo) and quite a number of similar products with same/similar names from different manufacturers. Not to mention the confusion that arises when you are posting external links or articles to the product and the link-url has changed because the "force update of friendly url" setting contributed to urls changing without realizing they had changed.

After more than 20 years of administering and owning e-commerce websites, I would NOT have or operate an e-commerce website that did not give a unique fixed reference (ID) in the url for every product. I would rather a visitor actually FIND the product they were looking for because the url had a fixed unique reference that allowed the website to determine the product they wanted - even when the rest of the url didn't exactly match whatever link the visitor followed to get to my website(s).

Just my .02 cents worth.

Edited by Obi
  • Like 1
Posted

@datakickI've experimented in 1.5. From what I can tell:

  • Changing a category works. The old URL redirects successfully.
  • Changing friendly URL does not work. The old URL does not redirect successfully.
  • Changing the schema to eg {categories:/}{id:/}{rewrite} from {categories:/}{rewrite} works. The old URL redirects successfully.

Is this correct or should changing friendly URL also work? 

  • 3 weeks later...
Posted

That's correct. Thirty bees is not remembering old rewrites. If you are not using id in your urls, then changing rewrite will cause 404.

I recommend to always use id in url schema

  • Like 2
Posted

Thank you!

I've now changed to {categories:/}{id:/}{rewrite} from {categories:/}{rewrite}.

Under "Redirect to the canonical URL" I have the recommended 301.

Does this mean that the change from the old schema to the new schema is communicated as a 301 redirect to search engines or do I have to add this to the htaccess file myself?

Posted
44 minutes ago, 30knees said:

Thank you!

I've now changed to {categories:/}{id:/}{rewrite} from {categories:/}{rewrite}.

Under "Redirect to the canonical URL" I have the recommended 301.

Does this mean that the change from the old schema to the new schema is communicated as a 301 redirect to search engines or do I have to add this to the htaccess file myself?

It's done automatically.

System will try to resolve urls without ID using product rewrite. So as long as your product rewrite remains the same, system will be able to perform 301 redirects automatically. 

For example. url

domain.com/en/cat-1/cat-2/cat-3/product-rewrite

will be redirected using 301 to

domain.com/en/cat-3/cat-9/123/product-rewrite

If you change product rewrite from 'product-rewrite' to 'whatever', then the link cease to exists, and original url will return 404.

Note that there we are working on a new premium module 404 manager that will give you some tools to map 404 links 

  • Like 1
  • 5 months later...
Posted

I'd like to revisit this.

I have {categories:/}{id:/}{rewrite} as the product rewrite.

Shouldn't domain.com/en/cat/123/typo automatically rewrite to domain.com/en/cat/123/correct? Because currently it doesn't. If I'm not mistaken, it used to work. Maybe I also just forgot to test last time. 

 

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...