PrestaShop Unfriendly URLs as Shortcuts

John Thomson
Oct 9, 2018 · 2 min read

PrestaShop has built in support for “friendly URLs”, that’s where you get things like this:

Image for post
Image for post
/12-cakes is quite friendly

This example shows:
/12-cakes
which is the friendlier version of this monstrosity:
/index.php?id_category=12&controller=category

Even though the ID number is in there, which takes away some of the neatness, it still makes address bar look a lot more friendly for the user.

There’s benefits to SEO and such as well, but that’s not why I’m writing this.

If I’m on a PrestaShop website, chances are I’m there to fix it, not buy something, so I don’t really care for these long, wordy, but SEO and human readable URLs. What I need is lots of shortcuts. I usually know the ID number of the product or category that I want to look at, and want to get there quickly.

Products

The easiest way, if the site has friendly URLs on, is to use the ID-.html trick.

Again, that’s ID, hyphen, dot, html.

This is the minimum I found to trick the friendly URL system to redirect to the full URL.

So, something like
example.com/1234-.html
would go to
example.com/category-name/1234-product-name.html

What about when friendly URLs isn’t enabled? Or if you want to do automated testing for example. It’s sometimes more efficient and reliable, especially if you’re telling a computer to do it, to use the ugly version.

example.com/index.php?controller=product&id_product=1234

This is a bit long winded to type, but it’ll work every time as long as the product exists.

Categories

It’s like the above trick, but with just the hyphen.

example.com/21-
would go to
example.com/21-awesome-category

That’s right, it’s literally just the category ID, then a hyphen. The friendly URL system takes care of the rest.

As for the ugly version, it’s similar to the one for the product:

example.com/index.php?controller=category&id_category=21


That’s basically all there is to it. There’s probably something you can do for the CMS pages too, but I barely touch them, so haven’t really looked.

Do you have any similar tricks to get to fiddly parts of the site? Let me know! :D

If you found this helpful, buy me a coffee. ;-)

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store