x
Loading
 Loading
Hello, Guest | Login | Register

Transform URLs with mod_rewrite

Much of the magic and convenience of the World Wide Web can be directly attributed to one simple but powerful construct: the Uniform Resource Locator, or URL. The shorthand of the Web, URLs provide a succinct and consistent way to refer to all kinds of online resources.

Much of the magic and convenience of the World Wide Web can be directly attributed to one simple but powerful construct: the Uniform Resource Locator, or URL. The shorthand of the Web, URLs provide a succinct and consistent way to refer to all kinds of online resources.

In the early days of the Internet, URLs were uncomplicated. The bulk of the Web’s content was stored in static pages on single servers, and URLs largely mimicked the hierarchy of the web site’s file system. Nowadays, URLs — and the resources they point to — are much more complex, as most content is stored in databases and is formatted and served on-the-fly. A single URL may disguise a cluster of load-balanced web servers or encode several bits of information in its query string.

While complex URLs work fine in the browser, sharing and bookmarking (and indexing) those URLs can be quite problematic. Email applications often scramble long URLs, and URLs filled with ? and & characters are hard for users to read and remember. Moreover, sites are rarely static. Keeping “legacy” URLs valid remains a challenge for an expanding site.

One solution to all of these URL problems is mod_rewrite, the “Swiss Army knife of URL manipulations,” written by Ralf S. Engelschall. mod_rewrite manipulates URLs quickly and easily, providing solutions to many URL construction problems.

For instance, mod_rewrite can let you simplify your URLs, or, if you ever reorganize your site, can easily transform older…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Helpful Tools for Software Developers
  2. The Github Hall of Fame
  3. Book'em, Github.
  4. This Week on Github: Stupid Ruby Tricks
  5. A Veritable Scatter Shot!
Follow Linux Magazine
Rackspace