Implementing routing
Routing refers to the process of accepting user-friendly URLs, dissecting the URL into its component parts, and then making a determination as to which class and method should be dispatched. The advantage of such an implementation is that not only can you make your URLs Search Engine Optimization (SEO)-friendly, but you can also create rules, incorporating regular expression patterns, which can extract values of parameters.
How to do it...
- Probably the most popular approach is to take advantage of a web server that supports URL rewriting. An example of this is an Apache web server configured to use
mod_rewrite
. You then define rewriting rules that allow graphic file requests and requests for CSS and JavaScript to pass untouched. ...
Get PHP 7 Programming Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.