Monday, November 4, 2013

Meaning and Purpose of Apache mod_rewrite module


REWRITE ENGINE

Meaning:
A rewrite engine is software located in a Web application framework running on a Web server that modifies a web URL's appearance. This modification is called URL rewriting. Rewritten URLs (sometimes known as short, 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. (refer http://en.wikipedia.org/wiki/Mod-rewrite)

Purpose:
The purpose of the rewrite engine is to rewrite a visitor’s request URI in the manner specified by a set of rules. (refer http://www.sitepoint.com/apache-mod_rewrite-examples/)

Benefits:
- The links are "cleaner" and more descriptive, improving their "friendliness" to both users and search engines.
- They prevent undesired "inline linking", which can waste bandwidth.
- They hide the inner workings of a web site's address to visitors, which can prevent them from discovering query strings that could compromise the site.
- 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).
(refer http://en.wikipedia.org/wiki/Mod-rewrite)

APACHE mod_rewrite:

The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, mod_rewritemaps a URL to a filesystem path. However, it can also be used to redirect one URL to another URL, or to invoke an internal proxy fetch.

mod_rewrite provides a flexible and powerful way to manipulate URLs using an unlimited number of rules. Each rule can have an unlimited number of attached rule conditions, to allow you to rewrite URL based on server variables, environment variables, HTTP headers, or time stamps.

mod_rewrite operates on the full URL path, including the path-info section. A rewrite rule can be invoked in httpd.conf or in .htaccess. The path generated by a rewrite rule can include a query string, or can lead to internal sub-processing, external request redirection, or internal proxy throughput.

(refer http://httpd.apache.org/docs/current/mod/mod_rewrite.html)

Guide: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
Example: http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/

No comments:

Post a Comment

Labels