URL rewriting
   HOME

TheInfoList



OR:

In web applications, a rewrite engine is a software component that performs
rewriting In mathematics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a formula with other terms. Such methods may be achieved by rewriting systems (also known as rewrite systems, rewrite engines, or reduc ...
on
URLs A Uniform Resource Locator (URL), colloquially termed as a web address, is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identi ...
(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 A web application (or web app) is application software that is accessed using a web browser. Web applications are delivered on the World Wide Web to users with an active network connection. History In earlier computing models like client-serv ...
. The engine is typically a component of a
web server A web server is computer software and underlying hardware that accepts requests via HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, commonly a web browser or web crawler, initia ...
or web application framework. Rewritten URLs (sometimes known as short, pretty or fancy URLs, search engine friendly - SEF URLs, or
slug Slug, or land slug, is a common name for any apparently shell-less terrestrial gastropod mollusc. The word ''slug'' is also often used as part of the common name of any gastropod mollusc that has no shell, a very reduced shell, or only a ...
s) are used to provide shorter and more relevant-looking links to web pages. The technique adds a layer of
abstraction Abstraction in its main sense is a conceptual process wherein general rules and concepts are derived from the usage and classification of specific examples, literal ("real" or " concrete") signifiers, first principles, or other methods. "An abst ...
between the files used to generate a web page and the URL that is presented to the outside world.


Usage

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 A wiki ( ) is an online hypertext publication collaboratively edited and managed by its own audience, using a web browser. A typical wiki contains multiple pages for the subjects or scope of the project, and could be either open to the pub ...
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 A blog (a Clipping (morphology), truncation of "weblog") is a discussion or informational website published on the World Wide Web consisting of discrete, often informal diary-style text entries (posts). Posts are typically displayed in Reverse ...
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 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 A search engine is a software system designed to carry out web searches. They search the World Wide Web in a systematic way for particular information specified in a textual web search query. The search results are generally presented in a ...
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 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

There are several benefits to using URL rewriting: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 An application server is a server that hosts applications or software that delivers a business application through a communication protocol. An application server framework is a service layer model. It includes software components available to a ...
platforms, make this irrelevant.
* The links are "cleaner" and more descriptive, improving their "friendliness" to both
users Ancient Egyptian roles * User (ancient Egyptian official), an ancient Egyptian nomarch (governor) of the Eighth Dynasty * Useramen, an ancient Egyptian vizier also called "User" Other uses * User (computing), a person (or software) using an ...
and
search engines A search engine is a software system designed to carry out web searches. They search the World Wide Web in a systematic way for particular information specified in a textual web search query. The search results are generally presented in ...
. * They prevent undesired " inline linking", which can waste bandwidth. * The site can continue to use the same URLs even if the underlying technology used to serve them is changed (for example, switching to a new blogging engine). 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. *
Apache HTTP Server The Apache HTTP Server ( ) is a free and open-source cross-platform web server software, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache S ...
has URL rewriting provided by the mod_rewrite module. * URL Rewrite is available as an extension to
Microsoft IIS Internet Information Services (IIS-pronounced 2S, formerly Internet Information Server) is an extensible web server software created by Microsoft for use with the Windows NT family. IIS supports HTTP, HTTP/2, HTTPS, FTP, FTPS, SMTP and N ...
. *
Ruby on Rails Ruby on Rails (simplified as Rails) is a server-side web application framework written in Ruby under the MIT License. Rails is a model–view–controller (MVC) framework, providing default structures for a database, a web service, and we ...
has built-in URL rewriting via Routes. * Jakarta Servlet has extendable URL rewriting via the OCPsoft URLRewriteFilter and Tuckey UrlRewriteFilter. * Jakarta Server Faces has 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. *
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
Stripes Framework has had integrated functionality since version 1.5. * Many Perl frameworks, such as Mojolicious and
Catalyst Catalysis () is the process of increasing the rate of a chemical reaction by adding a substance known as a catalyst (). Catalysts are not consumed in the reaction and remain unchanged after it. If the reaction is rapid and the catalyst recyc ...
, have this feature. *
CodeIgniter CodeIgniter is an open-source software rapid development web framework, for use in building dynamic web sites with PHP. Popularity CodeIgniter is loosely based on the popular model–view–controller (MVC) development pattern. While controller c ...
has URL rewriting provided. * lighttpd has a mod_rewrite module. *
nginx Nginx (pronounced "engine x" ) is a web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. The software was created by Igor Sysoev and publicly released in 2004. Nginx is free and open-source softw ...
has a rewrite module. For example, a multi-link multi-variable page generation from a URI lik

is possible, where multiple individual parts like get expanded with the help of regular expressions into variables to signify and so forth. * Hiawatha HTTP server has a URL Toolkit which supports URL rewriting. * Cherokee HTTP server supports regular expressions of URL rewriting and redirections. From a
software development Software development is the process of conceiving, specifying, designing, programming, documenting, testing, and bug fixing involved in creating and maintaining applications, frameworks, or other software components. Software development invo ...
perspective, URL rewriting can aid in code modularization and
control flow In computer science, control flow (or flow of control) is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an '' ...
, making it a useful feature of modern web frameworks.


See also

* Application Delivery Controller * aiScaler Traffic Manager * .htaccess *
Apache HTTP Server The Apache HTTP Server ( ) is a free and open-source cross-platform web server software, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache S ...
*
Content negotiation Content negotiation refers to mechanisms defined as a part of HTTP that make it possible to serve different versions of a document (or more generally, representations of a resource) at the same URI, so that user agents can specify which version f ...
*
HTTP The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide We ...
*
Internet Information Server Internet Information Services (IIS-pronounced 2S, formerly Internet Information Server) is an extensible web server software created by Microsoft for use with the Windows NT family. IIS supports HTTP, HTTP/2, HTTPS, FTP, FTPS, SMTP and N ...
* Permalink * Zeus Web Server


Notes


External links


Apache mod_rewrite
Full list of CGI variables and values for constructing rewrites. {{DEFAULTSORT:Rewrite Engine URL