Jump to content

Rewrite engine: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
Produke (talk | contribs)
Line 50: Line 50:


*[http://httpd.apache.org/docs/mod/mod_rewrite.html Apache's mod_rewrite]: a detailed discussion of mod_rewrite's many features.
*[http://httpd.apache.org/docs/mod/mod_rewrite.html Apache's mod_rewrite]: a detailed discussion of mod_rewrite's many features.
*[http://httpd.apache.org/docs/2.2/misc/rewriteguide.html Apache's URL rewriting guide]: more detailed discussion of mod_rewrite
*[http://www.askapache.com/2006/htaccess/htaccesselite-ultimate-htaccess-article.html/5/ Ultimate mod_rewrite]: The best tips, tricks, and examples
*[http://www.htaccesselite.com/htaccess/rewrites-and-redirects-vf4.html Using mod_rewrite in .htaccess files]: Using Rewrite in .htaccess forum
*[http://www.htaccesselite.com/htaccess/rewrites-and-redirects-vf4.html Using mod_rewrite in .htaccess files]: Using Rewrite in .htaccess forum
*[http://www.workingwith.me.uk/articles/scripting/mod_rewrite mod_rewrite, a beginner’s guide (with examples)]: a guide to get you started using mod_rewrite.
*[http://www.workingwith.me.uk/articles/scripting/mod_rewrite mod_rewrite, a beginner’s guide (with examples)]: a guide to get you started using mod_rewrite.

Revision as of 08:11, 23 March 2007

A rewrite engine is a piece of web server software used to modify URLs before fetching the requested item, for a variety of purposes. This technique is known as URL rewriting. Some benefits derived from a rewrite engine are:

Many of these only apply to HTTP servers whose default behaviour is to map URLs to filesystem entities (i.e. files and directories); certain environments, such as many HTTP application server platforms, make this irrelevant.

In practice

The Apache HTTP server has a rewrite engine called mod_rewrite, which has been described as "the Swiss Army knife of URL manipulation". A simpler module, mod_alias, allows for simpler rewriting.

Rewrite engines for Microsoft's Internet Information Server (IIS):

Rewrite HttpModule for Microsoft ASP.NET:

Rewrite engine for Java 2 Platform, Enterprise Edition (J2EE) Servlet container servers (such as Apache Tomcat, Resin, Orion etc):

  • HttpRedirectFilter (open source)
  • UrlRewriteFilter (open source) - allows you to rewrite URLs before they get to your Servlets, JSP's, Struts etc
  • URL Rewriter (open source - LGPL) - URL Rewriter is a tool for rewriting URLs in Java Servlets. It is similar to mod_rewrite.

In Java, the term "URL rewriting" is sometimes used to describe a Web Application Server adding a session id to a URL when cookies are not supported. (ie, "index.jsp" is rewritten to "index.jsp;jsessionid=xyc" when the links are drawn in an HTML page).

Ruby on Rails has built-in URL rewriting via Routes.[1]

User and search engine friendly URLs

People use website URLs in all kinds of ways. They send them to other people by email, put them on online discussion boards, or even write them on scraps of paper. This often applies not just to website home pages, but to specific content within a website. Typically website developers want to encourage this, as it means increased traffic to their sites. As such, a well designed website should allow users to enter at any URL (not just the homepage), and the URLs throughout the site should be easy to use.

A URL is easier to use if it is short but descriptive. The URL should have some text describing the content (not just numbers), but should not be too long.

Search engines will also find it easier to index pages which follow these rules. Content which is easier to index is more likely to be included in search results.

Website URLs are often quite long and quite meaningless to humans. This is because many websites have dynamic content, meaning that HTML returned to the browser is generated on-the-fly, rather than simply being stored as a static HTML file. The URL is used not only to reference an HTML document at a fixed address, but to pass pieces of data to software running on the webserver, which then generates the HTML page dynamically. Typically this software is of the form of scripts written in a web scripting language such as Perl, PHP, or ASP.

Using a URL rewrite engine, the website software can be presented with URLs in one form, while actual requests (and URLs seen by the user) are in another form. So rewrite engines allow URLs to be tidied up and made more user friendly, by configuring rewrite rules, rather than modifying the webserver software.

See also