HOME

TheInfoList



OR:

In
web application A web application (or web app) is application software that is created with web technologies and runs via a web browser. Web applications emerged during the late 1990s and allowed for the server to dynamically build a response to the request, ...
s, 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 (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 created with web technologies and runs via a web browser. Web applications emerged during the late 1990s and allowed for the server to dynamically build a response to the request, ...
. The engine is typically a component of a
web server A web server is computer software and underlying Computer hardware, hardware that accepts requests via Hypertext Transfer Protocol, HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, co ...
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 mollusc, 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 ...
s) are used to provide shorter and more relevant-looking links to web pages. The technique adds a layer of
abstraction Abstraction is a process where general rules and concepts are derived from the use and classifying of specific examples, literal (reality, real or Abstract and concrete, concrete) signifiers, first principles, or other methods. "An abstraction" ...
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 A query string is a part of a uniform resource locator ( URL) that assigns values to specified parameters. A query string commonly includes fields added to a base URL by a Web browser or other client application, for example as part of an HTML doc ...
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 a form of hypertext publication on the internet which is collaboratively edited and managed by its audience directly through a web browser. A typical wiki contains multiple pages that can either be edited by the public or l ...
page with title ''Rewrite_engine'' might be: http://example.com/w/index.php?title=Rewrite_engine but can be rewritten as: http://example.com/wiki/Rewrite_engine A
blog A blog (a Clipping (morphology), truncation of "weblog") is an informational website consisting of discrete, often informal diary-style text entries also known as posts. Posts are typically displayed in Reverse chronology, reverse chronologic ...
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 that provides hyperlinks to web pages, and other relevant information on World Wide Web, the Web in response to a user's web query, query. The user enters a query in a web browser or a mobile app, and the sea ...
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 URL-encoded by the browser before it makes the
HTTP request HTTP (Hypertext Transfer Protocol) 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 Web, wher ...
. 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. For a typical web application, the application server sits behind the web servers. An application ser ...
platforms, make this irrelevant.
* The links are "cleaner" and more descriptive, improving their "friendliness" to both users and
search engines Search engines, including web search engines, selection-based search engines, metasearch engines, desktop search tools, and web portals and vertical market websites have a search facility for online databases. By content/topic Gene ...
. * They prevent undesired "
inline linking Inline linking (also known as hotlinking, piggy-backing, direct linking, offsite image grabs, bandwidth theft, or leeching) is the practice of using or Embedding Rich Media, embedding a linked object—often an image—from one website onto a Web ...
", 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 software, free and open-source cross-platform web server, released under the terms of Apache License, Apache License 2.0. It is developed and maintained by a community of developers under the ...
has URL rewriting provided by the mod_rewrite module. * URL Rewrite is available as an extension to
Microsoft IIS Microsoft IIS (Internet Information Services, IIS, 2S) is an extensible web server created by Microsoft for use with the Windows NT family. IIS supports HTTP, HTTP/2, HTTP/3, HTTPS, FTP, FTPS, SMTP and NNTP. It has been an integral part of th ...
. * Ruby on Rails has built-in URL rewriting via Routes. * Jakarta Servlet has extendable URL rewriting via the OCPsoft URLRewriteFilter and Tuckey UrlRewriteFilter. *
Jakarta Faces Jakarta Faces, formerly Jakarta Server Faces and JavaServer Faces (JSF) is a Java specification for building component-based user interfaces for web applications. It was formalized as a standard through the Java Community Process as part of the ...
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 is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
Stripes Framework has had integrated functionality since version 1.5. * Many Perl frameworks, such as
Mojolicious Mojolicious is a real-time web application framework, written by Sebastian Riedel, creator of the web application framework Catalyst. Licensed as free software under the Artistic License v 2.0, it is written in the Perl programming language, and ...
and
Catalyst Catalysis () is the increase in rate of a chemical reaction due to an added substance known as a catalyst (). Catalysts are not consumed by the reaction and remain unchanged after it. If the reaction is rapid and the catalyst recycles quick ...
, have this feature. * CodeIgniter has URL rewriting provided. *
lighttpd lighttpd (prescribed pronunciation: "lighty") is an open-source web server optimized for speed-critical environments while remaining standards-compliant, secure and flexible. It was originally written by Jan Kneschke as a proof-of-concept of the ...
has a mod_rewrite module. *
nginx (pronounced "engine x" , stylized as NGINX or nginx) 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 Russian developer Igor Sysoev and publicly released in 20 ...
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 expression A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of characters that specifies a match pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
s 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 designing and Implementation, implementing a software solution to Computer user satisfaction, satisfy a User (computing), user. The process is more encompassing than Computer programming, programming, wri ...
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 software, free and open-source cross-platform web server, released under the terms of Apache License, Apache License 2.0. It is developed and maintained by a community of developers under the ...
*
Content negotiation In computing, 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 w ...
*
HTTP HTTP (Hypertext Transfer Protocol) 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 Web, wher ...
* Internet Information Server * Permalink * Zeus Web Server


Notes


External links


Apache mod_rewrite
{{DEFAULTSORT:Rewrite Engine URL