A rewrite engine is software that modifies a web URL's appearance (URL rewriting). Rewritten URLs (sometimes known as short or fancy URLs) are used to provide shorter and more relevant-looking links to web pages. The technique adds a degree of separation between the files used to generate a web page and the URL that is presented to the world.
Contents |
Examples
This URL contains query string parameters that encode blog entry dates
http://www.example.com/Blogs/Posts.php?Year=2006&Month=12&Day=19
but can be altered to give the user a clear idea of what he or she is going to see
http://www.example.com/Blogs/2006/12/19/
The second address also allows the user to change the URL to see all postings available in December, simply by removing the text encoding the day '19', and thereby saving having to navigate the GUI.
http://www.example.com/Blogs/2006/12/
Another example might be changing
http://example.com/wiki/index.php?title=Page_title
to
http://example.com/Page_title
The benefits of a rewrite engine are[1]:
- Making website URLs more descriptive to improve user-friendliness and search engine optimization
- Preventing undesired "inline linking"
- Not exposing the inner workings of a web site's address to visitors
- The URLs of pages on the web site can be kept even if the underlying technology used to serve them is changed
Known drawbacks:
- In some cases, for example if user modifies URL to get specified data the rewrite engine may hinder from querying. See below example:
-
- Which is a month and which is a day?
- http://www.example.com/Blogs/2006/12/10/
- In this case, a query that would be more useful is:
- http://www.example.com/Blogs/Posts.php?Year=2006&Month=12&Day=10
- Which is a month and which is a day?
Web frameworks
Many web frameworks include URL rewriting, either directly or through extension modules.
- Apache HTTP Server has URL rewriting provided by the mod_rewrite module
- URL Rewrite is available as an extension to Microsoft IIS [2]
- Ruby on Rails has built-in URL rewriting via Routes[3]
- Java Server Faces has URL rewriting via the PrettyFaces: URL rewriting extension for JSF
- Django uses a regular-expressions based system[4]
- Java Stripes Framework has had integrated functionality since version 1.5[5]
- Many Perl frameworks have this feature[citation needed]
From a software development perspective, URL rewriting can aid in code modularization and control flow [6], making it a useful feature of modern web frameworks.
See also
- Permalink
- Apache HTTP Server
- Internet Information Server
- Zeus Web Server
- Content negotiation
- HTTP
- .htaccess
Notes
- ^ Many of these only apply to HTTP servers whose default behavior is to map URLs to filesystem entities (i.e. files and directories); certain environments, such as many HTTP application server platforms, make this irrelevant.
- ^ Microsoft Web Platform
- ^ Routes
- ^ Django URLconf
- ^ clean urls in Stripes 1.5
- ^ DocForge: Clean URL
External links
Apache
- mod_rewrite Apache module described as "the Swiss Army knife of URL manipulation".
- Apache Rewrite Guide This document supplements the mod_rewrite reference documentation. It describes how one can use Apache's mod_rewrite to solve typical URL-based problems with which webmasters are commonly confronted.
- mod_alias Simpler Apache module allow for manipulation and control of URLs as requests arrive at the server.
IIS (Microsoft Internet Information Services)
- How to redirect URLs to different Web sites Microsoft Knowledgebase article on built-in URL rewriting
- Scott Guthrie of Microsoft describes various techniques for URL rewriting in .NET
- IIRF Ionic's ISAPI Rewriting Filter, for IIS5, 6, or 7. From Ionic Shade (free)
- URL Rewrite Module for IIS 7.0 from Microsoft
- URL Rewriter and Reverse Proxy for use on IIS 6.0 and 7.0 from Managed Fusion
Zeus Web Server
- Converting Apache rules to ZWS
- Redirecting clients to Alternate Pages
- Zeus Web Server User Guide see page 140 "Configuring Request Rewrite Scripts" (PDF 3.58MB)
Note: Unlike Apache, entering rewrite rules in an .htaccess file will not work. They must be entered in Zeus' proprietary Request Rewrite scripting language through the zeus server's admin panel, which creates a rewrite.script file and installs it into the server. Unless you have access to the main server administration interface, you will need to ask your hosting provider to implement your rule.
Java Platform, Enterprise Edition (Java EE) Servlet container servers (Apache Tomcat, Resin, Orion etc)
- HttpRedirectFilter (open source)
- UrlRewriteFilter (open source - BSD) - allows you to rewrite URLs before they get to your code. Supports XML or mod_rewrite style config.
This entry is from Wikipedia, the leading user-contributed encyclopedia. It may not have been reviewed by professional editors (see full disclaimer)




