31/01/2013

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.

Every 2 weeks, get the best ecommerce tips and latest trends in your inbox.

By submitting this form, I agree to the data entered being used by PrestaShop S.A for sending newsletters and promotional offers. You can unsubscribe at any time by using the link in the emails sent to you. Learn more about managing your data and rights.