Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Rewrite engine
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Web server component for mapping URLs}} {{About|URL rewriting|rewrite engines in mathematics and logic|Rewrite system|other uses|Rewrite (disambiguation){{!}}Rewrite}} {{primary sources|date=January 2011}} In [[web application]]s, 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 [[slug (web publishing)|slug]]s) 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|URL shortening}} Web sites with [[dynamic web page|dynamic content]] can use URLs that generate pages from the server using [[query string]] parameters. These are often rewritten to resemble URLs for [[static web page|static page]]s on a site with a [[folder (computing)|subdirectory hierarchy]]. For example, the URL to a [[wiki]] page with title ''Rewrite_engine'' might be: <nowiki>http://example.com/w/index.php?title=Rewrite_engine</nowiki> but can be rewritten as: <nowiki>http://example.com/wiki/Rewrite_engine</nowiki> A [[blog]] might have a URL that encodes the dates of each entry: <nowiki>http://www.example.com/Blog/Posts.php?Year=2006&Month=12&Day=19</nowiki> It can be altered like this: <nowiki>http://www.example.com/Blog/2006/12/19/</nowiki> 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: <nowiki>http://www.example.com/Blog/2006/12/</nowiki> 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]]: <nowiki>http://example.com/search term</nowiki> will be [[urlencode|URL-encode]]d by the browser before it makes the [[HTTP request]]. The server could rewrite this to: <nowiki>http://example.com/search.php?q=search%20term</nowiki> ==Benefits and drawbacks== {{Section OR|date=April 2013}} There are several benefits to using URL rewriting:<ref name="sidenote">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.</ref> * The links are "cleaner" and more descriptive, improving their "friendliness" to both [[usability|users]] and [[search engine optimization|search engines]]. * They prevent undesired "[[inline linking]]", which can waste [[bandwidth (computing)|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 [[blog software|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: <nowiki>http://www.example.com/Blog/06/04/02/</nowiki> In this case, the original query string was more useful, since the query variables indicated month and day: <nowiki>http://www.example.com/Blog/Posts.php?Year=06&Month=04&Day=02</nowiki> ==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.<ref>[http://httpd.apache.org/docs/current/mod/mod_rewrite.html mod_rewrite documentation]</ref> * URL Rewrite is available as an extension to [[Internet Information Services|Microsoft IIS]].<ref>[http://www.iis.net/download/URLRewrite URL Rewrite extension for Microsoft IIS]</ref> * [[Ruby on Rails]] has built-in URL rewriting via Routes.<ref>{{cite web|title=Rails Routing from the Outside In|url=http://guides.rubyonrails.org/routing.html|publisher="Ruby on Rails|access-date=25 April 2014}}</ref> * [[Jakarta Servlet]] has extendable URL rewriting via the OCPsoft URLRewriteFilter and Tuckey UrlRewriteFilter. * [[Jakarta Faces]] has simplified URL rewriting via the PrettyFaces: URLRewriteFilter. * [[Django (web framework)|Django]] uses a [[Regular expression|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.<ref>[http://docs.djangoproject.com/en/dev/topics/http/urls/#id1 Django URLconf]</ref> * [[Java (programming language)|Java]] [[Stripes (framework)|Stripes Framework]] has had integrated functionality since version 1.5.<ref>[http://greggbolinger.blogspot.com/2008/01/stripes-15-feature-clean-urls.html clean urls in Stripes 1.5]</ref> * Many Perl frameworks, such as [[Mojolicious]] and [[Catalyst (software)|Catalyst]], have this feature.<ref>[http://mojolicio.us/perldoc?Mojolicious/Guides/Routing Guides - Mojolicious guide to the galaxy]. Mojolicious. Retrieved on 2013-09-08.</ref> * [[CodeIgniter]] has URL rewriting provided. * [[lighttpd]] has a mod_rewrite module.<ref>[http://redmine.lighttpd.net/wiki/1/Docs:ModRewrite Docs ModRewrite - Lighttpd - lighty labs]. Redmine.lighttpd.net. Retrieved on 2013-09-08.</ref> * [[nginx]] has a rewrite module.<ref>{{cite web|url=http://nginx.org/r/rewrite |title=ngx_http_rewrite_module - rewrite |publisher=nginx.org |access-date=25 December 2014}}</ref><ref>{{cite mailing list |date=18 February 2013 |url=http://mailman.nginx.org/pipermail/nginx/2013-February/037592.html |mailing-list=nginx@nginx.org |title=A dynamic web-site written wholly in nginx.conf? Introducing mdoc.su! |first=Constantine A. |last=Murenin |access-date=24 December 2014}}</ref> For example, a multi-link multi-variable page generation from a [[URI]] like [http://mdoc.su/f101,n61,o56,d/ifconfig {{mono|/f101,n61,o56,d/ifconfig}}] is possible, where multiple individual parts like {{mono|f101}} get expanded with the help of [[regular expression]]s into variables to signify {{mono|[[FreeBSD]] 10.1-RELEASE}} and so forth. * [[Hiawatha (web server)|Hiawatha HTTP server]] has a URL Toolkit which supports URL rewriting.<ref>[http://www.hiawatha-webserver.org/manpages URL TOOLKIT part of Hiawatha webserver's manual]</ref> * [[Cherokee (Webserver)|Cherokee HTTP server]] supports regular expressions of URL rewriting and redirections. From a [[software development]] perspective, URL rewriting can aid in code modularization and [[control flow]],<ref>{{cite web|title=Clean URL|url=http://docforge.com/wiki/Clean_URL|publisher=DocForge|access-date=25 April 2014}}</ref> making it a useful feature of modern web frameworks. ==See also== * [[Application Delivery Controller]] * [[aiScaler|aiScaler Traffic Manager]] * [[.htaccess]] * [[Apache HTTP Server]] * [[Content negotiation]] * [[HTTP]] * [[Internet Information Server]] * [[Permalink]] * [[Zeus Web Server]] ==Notes== {{reflist|2}} ==External links== *[http://httpd.apache.org/docs/current/rewrite/ Apache mod_rewrite] <!--Interwikies--> {{DEFAULTSORT:Rewrite Engine}} [[Category:URL]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:About
(
edit
)
Template:Cite mailing list
(
edit
)
Template:Cite web
(
edit
)
Template:Mono
(
edit
)
Template:Primary sources
(
edit
)
Template:Reflist
(
edit
)
Template:Section OR
(
edit
)
Template:See also
(
edit
)
Template:Short description
(
edit
)