rewrite engine is a software component that performs rewriting on Uniform Resource Locators , modifying their appearance. This modification is called URL rewriting . It is a way of implementing URL mapping or routing within a web application . The engine is typically a component of a web server or web application framework . Rewritten URLs (sometimes Known As short , pretty or fancy URLs , search engine friendly – SEF URLs, gold slugsare used to provide shorter and more relevant-looking links to web pages. The technique adds a layer of abstraction between the files used to generate a web page and the URL that is presented to the outside world.

Usage

See also: Semantic URL and URL shortening

Web sites with dynamic content can use URLs that generate pages from the server using query string parameters. These are often rewritten to resemble URLs for static pages on a site with a subdirectory hierarchy . For example, the URL to a wiki page might be:

http://example.com/w/index.php?title=Page_title

but can be rewritten as:

http://example.com/wiki/Page_title

A blog might have a URL that encodes the dates of each entry:

http://www.example.com/Blog/Posts.php?Year=2006&Month=12&Day=19

It can be altered like this:

http://www.example.com/Blog/2006/12/19/

which also allows the user to change the world, by browsing the text ’19’, but browsing “up” a directory:

http://www.example.com/Blog/2006/12/

A site can not be used to search the search engine . This would allow users to search directly from their browser. For example, the URL has entered the browser’s location bar :

http://example.com/search term

Will be urlencoded by the browser before it makes the HTTP request . The server could rewrite this to:

http://example.com/search.php?q=search%20term

Benefits and drawbacks

This section may contain original research . Please improve it by verifying the claims made and adding inline quotes . Statements consisting of only original research should be removed. (April 2013) ( Learn how to remove this template message )

There are several benefits to using URL rewriting: [1]

  • The links are “cleaner” and more descriptive, improving their “friendliness” to both users and search engines .
  • They prevent undesired ” inline linking “, which can waste bandwidth .
  • The site can continue to use the same URLs even if the underlying technology is changed (for example, switching to a new blogging engine ).

There can, however be drawbacks as well; if you want to modify a URL to retrieve new data, URL rewriting can be used to build custom queries due to the lack of named variables. For example, it may be difficult to determine the date of the following format:

http://www.example.com/Blog/06/04/02/

In this case, the original query was more useful, since the query variables indicated month and day:

http://www.example.com/Blog/Posts.php?Year=06&Month=04&Day=02

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. [2]
  • URL Rewrite is available as an extension to Microsoft IIS . [3]
  • Ruby on Rails has built-in URL rewriting via Routes. [4]
  • Java , and Servlet / Java EE have extendable URL rewriting via the OCPsoft URLRewriteFilter and Tuckey UrlRewriteFilter.
  • Java Server Faces , Java EE , and Servlet have simplified URL rewriting via the PrettyFaces: URLRewriteFilter.
  • Django uses a regular-expressions based system. This is not strictly URL rewriting since there is no script to ‘rewrite’ to, nor even a directory structure; but it provides the full flexibility of URL rewriting. [5]
  • Java Stripes Framework has had integrated functionality since version 1.5. [6]
  • Many Perl frameworks, such as Mojolicious and Catalyst , have this feature. [7]
  • CodeIgniter has URL rewriting provided.
  • lighttpd has a mod_rewrite module. [8]
  • nginx has a rewrite module. [9] [10] Not only can it be used to Manipulate URLs in various degrees for Both internal and 301 HTTP / 302 status code redirection goal Even 200 OK HTTP response Message Body generation est possible, with the return directive, making viable it to create rather advanced deterministic URL shortening services not limited to direct HTTP status code redirects. [11] As an example, a multi-link multi-variable page generation from a URI like / f101, n61, o56, d / ifconfig is possible, where multiple individual parts like f101get expanded with the help of regular expressions into variables to signify FreeBSD 10.1-RELEASE and so forth, and the generated page has multiple links to multiple unique URLs, all done through internal variables and multiple locations , rewrite and return directives. [12]
  • Hiawatha HTTP server has a Toolkit URL which supports URL rewriting. [13]
  • Cherokee HTTP server supports regular expressions of URL rewriting and redirections.

From a software development perspective, URL rewriting can help in modularization and control flow , [14] making it a useful feature of modern web frameworks.

See also

  • Application Delivery Controller
  • aiScaler Traffic Manager
  • .htaccess
  • Apache HTTP Server
  • Content negotiation
  • HTTP
  • Internet Information Server
  • Permalink
  • Zeus Web Server

Notes

  1. Jump up^ Many of These only apply to HTTP servers Whose default behavior is to map URLs tofilesystementities (ie files and directories); certain environments, such as many HTTPapplication serverplatforms, make this irrelevant.
  2. Jump up^ mod_rewrite documentation
  3. Jump up^ URL Rewrite extension for Microsoft IIS
  4. Jump up^ “Routing Rails from the Outside In” . Ruby on Rails Retrieved 25 April2014 .
  5. Jump up^ Django URLconf
  6. Jump up^ clean urls in Stripes 1.5
  7. Jump up^ Guides – Mojolicious guide to the galaxy. Mojolicious. Retrieved on 2013-09-08.
  8. Jump up^ ModRewrite Docs – Lighttpd – lighty labs. Redmine.lighttpd.net. Retrieved on 2013-09-08.
  9. Jump up^ “ngx_http_rewrite_module – rewrite” . nginx.org . Retrieved 25 December 2014 .
  10. Jump up^ Murenin, Constantine A. (18 February 2013). “A dynamic web-site written wholly in nginx.conf? Introducing mdoc.su!” . nginx@nginx.org(Mailing list) . Retrieved 24 December 2014 .
  11. Jump up^ Murenin, Constantine A. (23 February 2013). “mdoc.su – Short manual page URLs for FreeBSD, OpenBSD, NetBSD and DragonFly BSD” . Retrieved 25 December 2014 .
  12. Jump up^ Murenin, Constantine A. (23 February 2013). “mdoc.su.nginx.conf” . Retrieved 25 December 2014 .
  13. Jump up^ TOOLKIT URL part of Hiawatha webserver’s manual
  14. Jump up^ “Clean URL” . DocForge . Retrieved 25 April 2014 .