Recipe 43 | Rewriting URLs to Preserve Links |
Problem
We plan to redesign our site around a new content-management system (CMS), and our URLs are going to change as a result. We have a lot of incoming links to pages and don’t want to lose out on that traffic. Trying to figure out who links to us and asking them to change the links would take a lot of work and isn’t a reasonable plan; nor is leaving the old pages around with a link to the new ones. We need a way to redirect users from the old URLs to the new ones with as little overhead as possible.
Ingredients
-
The Apache web server
-
mod_rewrite
Solution
The Apache web server and mod_rewrite—an Apache module that lets you make custom and simplified URLs—enable us to tell the server to load a specified ...
Get Web Development Recipes, 2nd Edition 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.