O'Reilly logo

Web Development Recipes, 2nd Edition by Chris Johnson, Mike Weber, Chris Warren, Brian P. Hogan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Recipe 43Rewriting 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required