Jump to Navigation

294 - mod_rewrite mod_alias

1. mod_rewrite

This module uses a rule-based rewriting engine (based on a regular-expression parser) to rewrite requested URLs on the fly. It supports an unlimited number of rules
and an unlimited number of attached rule conditions for each rule, to provide a really flexible and powerful URL manipulation mechanism.
The URL manipulations can depend on various tests, of server variables, environment variables, HTTP headers, or time stamps.
Even external database lookups in various formats can be used to achieve highly granular URL matching.

This module operates on the full URLs (including the path-info part) both in per-server context (httpd.conf) and per-directory context (.htaccess)
and can generate query-string parts on result. The rewritten result can lead to internal sub-processing, external request redirection or even
to an internal proxy throughput.

Ex.

RewriteEngine On
RewriteRule /.* http://www.yourserver.com/ [R]

2. mod_alias

The directives contained in this module allow for manipulation and control of URLs as requests arrive at the server. The Alias
and ScriptAlias directives are used to map between URLs and filesystem paths. This allows for content which is not directly
under the DocumentRoot served as part of the web document tree. The ScriptAlias directive has the additional effect of marking
the target directory as containing only CGI scripts.

The Redirect directives are used to instruct clients to make a new request with a different URL. They are often used
when a resource has moved to a new location.

Ex.

Redirect / http://www.yourserver.com/

Redirect permanent / http://www.yourserver.com/

Redirect /old.html http://www.yourserver.com/new.html

 



Main menu 2

Story | by Dr. Radut