Rewrite engine explained

In web applications, a rewrite engine is a software component that performs rewriting on URLs (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, or slugs) are 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 with title Rewrite_engine might be: http://example.com/w/index.php?title=Rewrite_enginebut can be rewritten as: http://example.com/wiki/Rewrite_engine

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=19It can be altered like this: http://www.example.com/Blog/2006/12/19/which also allows the user to change the URL to see all postings available in December, simply by removing the text encoding the day '19', as though navigating "up" a directory: http://www.example.com/Blog/2006/12/

A site can pass specialized terms from the URL to its search engine as a search term. This would allow users to search directly from their browser. For example, the URL as entered into the browser's location bar: http://example.com/search termwill be URL-encoded 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

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

There can, however be drawbacks as well; if a user wants to modify a URL to retrieve new data, URL rewriting may hinder the construction of custom queries due to the lack of named variables. For example, it may be difficult to determine the date from the following format: http://www.example.com/Blog/06/04/02/In this case, the original query string 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.

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

See also

External links

Notes and References

  1. 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.
  2. http://httpd.apache.org/docs/current/mod/mod_rewrite.html mod_rewrite documentation
  3. http://www.iis.net/download/URLRewrite URL Rewrite extension for Microsoft IIS
  4. Web site: Rails Routing from the Outside In. "Ruby on Rails. 25 April 2014.
  5. http://docs.djangoproject.com/en/dev/topics/http/urls/#id1 Django URLconf
  6. http://greggbolinger.blogspot.com/2008/01/stripes-15-feature-clean-urls.html clean urls in Stripes 1.5
  7. http://mojolicio.us/perldoc?Mojolicious/Guides/Routing Guides - Mojolicious guide to the galaxy
  8. http://redmine.lighttpd.net/wiki/1/Docs:ModRewrite Docs ModRewrite - Lighttpd - lighty labs
  9. Web site: ngx_http_rewrite_module - rewrite . nginx.org . 25 December 2014.
  10. 18 February 2013 . A dynamic web-site written wholly in nginx.conf? Introducing mdoc.su! . nginx@nginx.org . Constantine A. . Murenin . 24 December 2014.
  11. http://www.hiawatha-webserver.org/manpages URL TOOLKIT part of Hiawatha webserver's manual
  12. Web site: Clean URL. DocForge. 25 April 2014.