Web server - Rewrite engine

From XennisWiki
(Redirected from Rewrite engine)
Jump to: navigation, search

A rewrite engine is software located in a Web application framework running on a Web server that modifies a web URL's appearance [...]. Rewritten URLs 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. (Wikipedia)

Apache HTTP Server - Module mod_rewrite

Further information: Apache Module mod_rewrite, Umleitungen mit mod_rewrite, mod_rewrite, a beginner’s guide , mod_rewrite FAQ

Flags: Übersicht, Details

Examples

See Apache mod_rewrite Examples for more examples.

Simple redirect

.htaccess (File in the directory scripts/apache/redirect)

# Forwarding of: http://YOUR-DOMAIN.de/scripts/apache/redirect/CSS-FILE-NAME
# to:            http://jigsaw.w3.org/css-validator/validator?uri=http://YOUR-DOMAIN.org/css/CSS-FILE-NAME.css
RewriteEngine on
RewriteBase /scripts/apache/redirect
RewriteRule ^([^/\.]+)/?$ http://jigsaw.w3.org/css-validator/validator?uri=http://YOUR-DOMAIN.org/css/$1.css&profile=css3 [L]

MediaWiki

see Use short URL

.htaccess (in the root directory of your omain)

# Forwarding of: http://YOUR-DOMAIN.org/w/index.php?index.php?title=ARTICLE
# to:            http://YOUR-DOMAIN.org/wiki/ARTICLE
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ /w/index.php [PT,L,QSA]
RewriteRule ^/*$ /w/index.php [L,QSA]

See also