Ecommerce Blog - The #1 Source for Ecommerce News, Tips and Trends!

Get ecommerce updates, news, and insider tips from the experts at PrestaShop!

Ecommerce Blog - The #1 Source for Ecommerce News, Tips and Trends!
 

< Back to the Blog home

Custom URL Routing for PrestaShop Modules

PrestaShop v1.5 revolutionized the way you control and customize URLs. From Friendly URLs, to customized URL routing, PrestaShop is the e-commerce software on the forefront of URL capabilities.

In v1.5.3, we’ve added a small new feature to the URL dispatcher to further enhance URL rewriting capabilities. It is now possible to add custom URL routes for modules. Let’s see how it works.

Here’s an example:
Let’s name a new Module called “mymodule”.
“mymodule” has two main functions.

1) It will show a page list of commands for any user on your site
2) You can use “mymodule” to see the details of an order

Page list of commands

  • Friendly URL Disabled: http://www.yourstore.com/index.php?fc=module&module=monmodule&controller=orders&module_action=listing
  • Friendly URL Enabled: http://www.yourstore.com/module/monmodule/orders?module_action=listing

Details of an order

  • Friendly URL Disabled: http://www.yourstore.com/index.php?fc=module&module=monmodule&controller=orders&module_action=details&id_order=42
  • Friendly URL Enabled: http://www.yourstore.com/module/monmodule/orders?module_action=details&id_order=42

The principle of using Friendly URLs is to have nice, clean, SEO Friendly URLs that are naturally readable by search engines and customers alike. However, even with Friendly URLs turned on, sometimes the URLs can still look strange. This is clearly the case with the two examples above, even with Friendly URLs turned on.

PrestaShop v1.5.3 comes equipped with the ability to add custom routes for a module. Using Friendly URLs, alongside with a custom route for the module we created, allows us to alter each URL to look fresh and clean. Check out the URLs now that we’ve added a custom route.

  • 1) Page list of commands
    http://www.yourstore.com/module/mymodule/orders/listing
  • 2) Details of an Order
    http://www.yourstore.com/module/mymodule/orders/details/42

The difference is remarkable. In the above examples, you can now see how much easier the URLs are to read. This is an example of the awesome power and control you have over your URLs by using PrestaShop.

If you have a server that can handle URL rewriting, and have Friendly URL’s turned on, you can navigate to Preferences>SEO and URL’s> Schema of URL’s to view all the customization features you can add.

  1. Author: Grox

    Date: February 1, 2013 at 12:49 pm

    There is a critical BUG and a ticket for it: SEF URL scheme not working anymore from version 1.5.3

    You can change the scheme, but it wont work.

    I assume, that this is a critical bug that can easily broke most links to your shop from Search Engines.

  2. Well, this article shows what exactly prestashop mean – it means: Awesome! :)

  3. Author: benjamin utterback

    Date: February 12, 2013 at 2:30 pm

    Hi Grox, we actually have updated the classes>dispatcher.php recently. Check out the changes in the Development branch on Github here https://github.com/PrestaShop/PrestaShop/commit/fed600132611d7f2aba799a0c61cd8d79fea35ec

  4. Author: Dick Chainey

    Date: June 18, 2013 at 12:22 pm

    A very annoying post telling us “hey, there’s a great new feature” but does not state anywhere how to implement it…

    • Author: benjamin utterback

      Date: June 18, 2013 at 1:23 pm

      Hey Dick,

      Sorry you felt this post annoying. If something is confusing you, please let me know and I can explain. As for the implementation of the URL Schemas, I’ll quote the last paragraph of the blogpost. “If you have a server that can handle URL rewriting, and have Friendly URL’s turned on, you can navigate to Preferences>SEO and URL’s> Schema of URL’s to view all the customization features you can add.”

      If you are running v1.5.3+ what this basically says is if your server can support URL rewriting and it’s enabled in your back-office. Then you can navigate to Preferences>SEO and URL’s>(scroll down) and view “Schema of URL’s to view all the customization features you can add to your URLs. Check out this link for more information: http://www.inmotionhosting.com/support/edu/prestashop-15/343-alter-sef-url-format
      I hope that now you can understand how to implement this new feature. Thanks for reading.

      Cheers,

      Benjamin

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>