The Dispatcher
The Dispatcher is one of the main technical features of v1.5. It handles URL redirections. Instead of using multiple files in the root folder like product.php
, order.php
or category.php
, only one file is used: index.php
. From now on, internal URL will look like index.php?controller=category
, index.php?controller=product
, etc.
Additionally, the Dispatcher is built to support URL rewriting. Therefore, when URL-rewriting is off, PrestaShop will use the following URL form:
http://myprestashop.com/index.php?controller=category&id_category=3&id_lang=1 http://myprestashop.com/index.php?controller=product&id_product=1&id_lang=2
...and when URL-rewriting is on (or "Friendly URLs"), PrestaShop's Dispatcher will correctly support this URL form:
http://myprestashop.com/en/3-music-ipods http://myprestashop.com/fr/1-ipod-nano.html
There are several advantages for this system:
- It is easier to add a controller.
- You can use custom routes to change your friendly URLs (which is really better for SEO!)
- There is only one single entry point into the software, which improves PrestaShop's reliability, and facilitates future developments.
The Dispatcher makes use of three abstract classes: Controller
, FrontController
and AdminController
(the last two inheriting from the first one).
New routes can be created by overriding the loadRoutes()
method.
The store administrator can change a controller's URL using the "SEO & URLs" page in the back-office's "Preferences" menu.