Enabling overrides and performing URL rewriting

This recipe teaches you how to use mod_rewrite. I mentioned mod_rewrite earlier; it is a module for Apache that allows us to modify the URL and resolve it to different resources. There are many reasons one would want to do this. For example, perhaps you moved some files and their URL changed, but you don't want any links that exist elsewhere still pointing to the old destinations to be broken. You can write a rewrite rule that matches the old locations and updates the URL on the fly to successfully satisfy the request. Another example is SEO; you may have long, unfriendly canonical URLs for a resource but want something shorter and more memorable. The friendly URLs can be mapped to the canonical ...

Get CentOS 7 Server Deployment 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.