30knees Posted July 15, 2023 Posted July 15, 2023 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: 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. 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!
led24ee Posted July 15, 2023 Posted July 15, 2023 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. 1
30knees Posted July 15, 2023 Author Posted July 15, 2023 Agree - category name in the URL is not necessary. I'm also thinking about dropping the product name and just having an ID.
led24ee Posted July 15, 2023 Posted July 15, 2023 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.
30knees Posted July 16, 2023 Author Posted July 16, 2023 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.
datakick Posted July 16, 2023 Posted July 16, 2023 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 looking into db if product with given rewrite exists 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. 2
30knees Posted July 16, 2023 Author Posted July 16, 2023 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!
datakick Posted July 17, 2023 Posted July 17, 2023 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. 1
30knees Posted October 14, 2023 Author Posted October 14, 2023 Has this been implemented in 1.5? On 7/16/2023 at 9:02 AM, datakick said: I will probably fix this in bleeding edge / 1.5
Obi Posted October 29, 2023 Posted October 29, 2023 (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 looking into db if product with given rewrite exists 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 October 29, 2023 by Obi 1
30knees Posted October 31, 2023 Author Posted October 31, 2023 Thanks for your thoughts. It sounds like a schema like {categories:/}{id}-{rewrite} would be the best of both worlds.
30knees Posted November 4, 2023 Author Posted November 4, 2023 @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?
datakick Posted November 22, 2023 Posted November 22, 2023 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 2
30knees Posted November 23, 2023 Author Posted November 23, 2023 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?
datakick Posted November 23, 2023 Posted November 23, 2023 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 1
30knees Posted May 14 Author Posted May 14 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.
30knees Posted May 16 Author Posted May 16 (edited) @datakick in case you missed this one (because you kindly replied elsewhere in the meantime). :) Edited May 16 by 30knees
30knees Posted June 20 Author Posted June 20 datakick took a look and the correct version is: {categories}/{id}/{rewrite}\n
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now