Module mod_rewrite
Module mod_rewrite supports directives for the IBM® HTTP Server for i Web server.
Summary
This module allows you to control URL access to your HTTP Server.
For example, to prevent a particular user agent called Web crawler from accessing any pages on the server. To do this, include the following directives in your configuration:
RewriteEngine on RewriteCond %{HTTP_USER_AGENT} ^Webcrawler RewriteRule ^.*$ - [F,L]
The first line enables the rewrite engine. The second line provides a test that returns true if the HTTP_USER_AGENT string starts with the letters Web crawler. If the second line is true, then the third line takes any URL string and returns a forbidden message to the client.
Directives
RewriteBase
Module: mod_rewrite | |
Syntax: RewriteBase Base_URL | |
Default: RewriteBase physical directory path | |
Context: Directory, but not Location, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: RewriteBase /xyz |
The RewriteBase directive explicitly sets the base URL for per-directory rewrites. As you will see below, RewriteRule can be used in per-directory config files (.htaccess). There it will act locally (for example, the local directory prefix is stripped at this stage of processing and your rewriting rules act only on the remainder). At the end it is automatically added back to the path.
When a substitution occurs for a new URL, this module has to re-inject the URL into the processing server. To be able to do this it needs to know what the corresponding URL-prefix or URL-base is. By default this prefix is the corresponding filepath itself. At most, Web sites URLs are not directly related to physical filename paths, so this assumption is usually incorrect. In this case, you have to use the RewriteBase directive to specify the correct URL-prefix.
Assume the following per-directory configuration file (/abc/def is the physical path of /xyz, and the server has the 'Alias /xyz /ABC/def' established).
RewriteEngine On
RewriteBase /xyz
RewriteRule ^old\.html$ new.html
In the above example, a request to /xyz/old.html is correctly rewritten to the physical file /ABC/def/new.html.
RewriteCond
Module: mod_rewrite | |
Syntax: RewriteCond TestString CondPattern [flags] | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: RewriteCond %{HTTP_USER_AGENT} ^Mozilla.* |
The RewriteCond directive defines a rule condition. Precede a RewriteRule directive with one or more RewriteCond directives. The following rewriting rule is only used if its pattern matches the current state of the URI and if these additional conditions apply.
- Parameter One: TestString
- The TestString parameter can contain the following expanded
constructs in addition to plain text:
- RewriteRule backreferences: These are backreferences of
the form.
- $N
- (0 <= N <= 9) that provide access to the grouped sections (those in parenthesis) of the pattern from the corresponding RewriteRule directive (the one following the current RewriteCond directives).
- RewriteCond backreferences: These are backreferences of
the form.
- %N
- 0 <= N <= 9) that provide access to the grouped sections (those in parenthesis) of the pattern from the last matched RewriteCond directive in the current conditions
- RewriteMap expansions: These are expansions of the form.
- ${mapname:key|default}
- See RewriteMap for more details.
- Server-Variables: These are variables of the form
- %{ NAME_OF_VARIABLE }
- Where NAME_OF_VARIABLE can be a string taken from the following
list:
- HTTP headers
- HTTP_USER_AGENT
- HTTP_REFERRER
- HTTP_COOKIE
- HTTP_FORWARDED
- HTTP_HOST
- HTTP_PROXY_CONNECTION
- HTTP_ACCEPT
- Connection and Request
- REMOTE_ADDR
- REMOTE_HOST
- REMOTE_USER
- REMOTE_IDENT
- REQUEST_METHOD
- SCRIPT_FILENAME
- PATH_INFO
- QUERY_STRING
- AUTH_TYPE
- Server Internals
- DOCUMENT_ROOT
- SERVER_ADMIN
- SERVER_NAME
- SERVER_ADDR
- SERVER_PORT
- SERVER_PROTOCOL
- SERVER_SOFTWARE
- System
- TIME_YEAR
- TIME_MON
- TIME_DAY
- TIME_HOUR
- TIME_MIN
- TIME_SEC
- TIME_WDAY
- TIME
- Special
- API_VERSION
- THE_REQUEST
- REQUEST_URI
- REQUEST_FILENAME
- IS_SUBREQ
Tip:- The variables SCRIPT_FILENAME and REQUEST_FILENAME contain the same value (the value of the filename field of the internal request_rec structure of the server). The first name is just the commonly known CGI variable name while the second is the consistent counterpart to REQUEST_URI (which contains the value of the URI field of request_rec).
- There is the special format: %{ENV:variable} where variable can be any environment variable. This is looked-up via internal structures and (if not found there) via getenv() from the server process.
- There is the special format: %{HTTP:header} where header can be any HTTP MIME-header name. This is looked-up from the HTTP request. Example: %{HTTP:Proxy-Connection} is the value of the HTTP header ``Proxy-Connection:''.
- There is the special format %{LA-U:variable} for look-aheads that perform an internal (URL-based) sub-request to determine the final value of variable. Use this when you want to use a variable for rewriting (which is actually set later in an API phase and thus is not available at the current stage). For instance when you want to rewrite according to the REMOTE_USER variable from within the per-server context (httpd.conf file) you have to use %{LA-U:REMOTE_USER} because this variable is set by the authorization phases that come after the URL translation phase where mod_rewrite operates. On the other hand, because mod_rewrite implements its per-directory context (.htaccess file) via the Fixup phase of the API and because the authorization phases come before this phase, you just can use %{REMOTE_USER} there.
- There is the special format: %{LA-F:variable} that performs an internal (filename-based) sub-request to determine the final value of variable. Most of the time this is the same as LA-U above.
- RewriteRule backreferences: These are backreferences of
the form.
- The TestString parameter can contain the following expanded
constructs in addition to plain text:
- Parameter Two: CondPattern
- The CondPattern parameter is the condition pattern (a regular
expression) that is applied to the current instance of the TestString.
TestString is evaluated and then matched against CondPattern.
CondPattern is a standard Extended Regular Expression with some additions:
- You can prefix the pattern string with a '!' character (exclamation mark) to specify a non-matching pattern.
- There are some special CondPattern variants. Instead of real regular
expression strings you can also use one of the following:
- <CondPattern
- Treats the CondPattern as a plain string and compares it lexically to TestString. True if TestString is lexically lower than CondPattern.
- >CondPattern
- Treats the CondPattern as a plain string and compares it lexically to TestString. True if TestString is lexically greater than CondPattern.
- =CondPattern
- Treats the CondPattern as a plain string and compares it lexically to TestString. True if TestString is lexically equal to CondPattern (the two strings are exactly equal, character by character). If CondPattern is just "" (two quotation marks) this compares TestString to the empty string.
- -d
- Treats the TestString as a pathname and tests if it exists and is a directory.
- -f
- Treats the TestString as a pathname and tests if it exists and is a regular file.
- -s
- Treats the TestString as a pathname and tests if it exists and is a regular file with size greater than zero.
- -l
- Treats the TestString as a pathname and tests if it exists and is a symbolic link.
- -F
- Checks if TestString is a valid file and accessible via all the server's currently-configured access controls for that path. This uses an internal subrequest to determine the check.
- -U
- Checks if TestString is a valid URL and accessible via all the server's currently-configured access controls for that path. This uses an internal subrequest to determine the check.
Note: All of these tests can also be prefixed by an exclamation mark ('!') to negate their meaning.
- The CondPattern parameter is the condition pattern (a regular
expression) that is applied to the current instance of the TestString.
TestString is evaluated and then matched against CondPattern.
- Parameter Three: flags
- The flags parameter is appended to the CondPattern parameter.
The flags parameter is a comma -serapertaed list of the following
flags:
- nocase|NC
- This makes the test case-insensitive (there is no difference between 'A-Z' and AZ both in the expanded TestString and the CondPattern). This flag is effective only for comparisons between TestString and CondPattern. It has no effect on filesystem and subrequest checks.
- ornext|OR
- Use this to combine rule conditions with a local OR instead of
the implicit AND. Typical example:
Without this flag you would have to write the cond/rule three times.RewriteCond %{REMOTE_HOST} ^host1.* [OR] RewriteCond %{REMOTE_HOST} ^host2.* [OR] RewriteCond %{REMOTE_HOST} ^host3.* RewriteRule ...some special stuff for any of these hosts...
- The flags parameter is appended to the CondPattern parameter.
The flags parameter is a comma -serapertaed list of the following
flags:
To rewrite the Homepage of a site according to the ``User-Agent:'' header of the request, you can use the following:
RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
RewriteRule ^/$ /homepage.max.html [L]
RewriteCond %{HTTP_USER_AGENT} ^Lynx.*
RewriteRule ^/$ /homepage.min.html [L]
RewriteRule ^/$ /homepage.std.html [L]
If you use Netscape Navigator as your browser (which identifies itself as 'Mozilla'), then you get the max homepage, which includes Frames and so on. If you use the Lynx browser (which is Terminal-based), then you get the min homepage, which contains no images, no tables, and so on. If you use any other browser you get the standard homepage.
RewriteEngine
Module: mod_rewrite | |
Syntax: RewriteEngine on | off | |
Default: RewriteEngine off | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: RewriteEngine on |
The RewriteEngine directive enables or disables the runtime rewriting engine. You can use this directive to disable the module instead of commenting out all the RewriteRule directives.
- Parameter: on | off
- If set to on runtime processing is enabled. If it is set to off runtime processing is disabled and this module does not runtime processing at all.
RewriteLog
Module: mod_rewrite | |
Syntax: RewriteLog filename | |
Default: none | |
Context: server config, virtual host | |
Override: none | |
Origin: Apache | |
Example: RewriteLog "/usr/local/var/apache/logs/rewrite.log" |
The RewriteLog directive sets the name of the file to which the server logs any rewriting actions it performs. The directive should occur only once per server configuration.
- Parameter One: filename
- The filename parameter is any valid filename that QTMHHTTP
has authority to write to. If the name does not begin with a slash
('/') then it is assumed to be relative to the Server Root. For example,
RewriteLog "/usr/local/var/apache/logs/rewrite.log"
- The filename parameter is any valid filename that QTMHHTTP
has authority to write to. If the name does not begin with a slash
('/') then it is assumed to be relative to the Server Root. For example,
RewriteLogLevel
Module: mod_rewrite | |
Syntax: RewriteLogLevel Level | |
Default: RewriteLogLevel 0 | |
Context: server config, virtual host | |
Override: none | |
Origin: Apache | |
Example: RewriteLogLevel 3 |
The RewriteLogLevel directive sets the level of the rewriting logfile.
- Parameter: Level
- The Level parameter sets the level of the rewriting logfile. The
default level 0 means no logging, while 9 means that practically all
actions are logged. For example,
To disable the logging of rewriting actions simply set Level to 0. This disables all rewrite action logs.RewriteLogLevel 3
- The Level parameter sets the level of the rewriting logfile. The
default level 0 means no logging, while 9 means that practically all
actions are logged. For example,
RewriteMap
Module: mod_rewrite | |
Syntax: RewriteMap MapName MapType:MapSource | |
Default: none | |
Context: server config, virtual host | |
Override: none | |
Origin: Apache | |
Example: RewriteMap servers rnd:/path/to/file/map.txt |
The RewriteMap directive defines a Rewriting Map that can be used inside rule substitution strings by the mapping-functions to insert or substitute fields through a key lookup. The source of this lookup can be of various types.
- Parameter: MapName
- The MapName parameter is the name of the map and is used
to specify a mapping-function for the substitution strings of a rewriting
rule via one of the following constructs:
${ MapName : LookupKey } ${ MapName : LookupKey | DefaultValue }
When such a construct occurs the map MapName is consulted and the key LookupKey is looked-up. If the key is found, the map-function construct is substituted by SubstValue. If the key is not found then it is substituted by DefaultValue or by the empty string if no DefaultValue was specified. The following combinations for MapType and MapSource can be used:
- Standard Plain Text
- MapType: txt, MapSource: Path to a file
This is the standard rewriting map feature where the MapSource is a plain text file containing either blank lines, comment lines (starting with a '#' character) or pairs like the following (one per line): MatchingKey SubstituionValue.
File example:
## ## map.txt -- rewriting map ## Ralf.B.Jones rbj # Operator Mr.Joe.Average joe # Mr. Average
Directive example:
RewriteMap real-to-user txt:/path/to/file/map.txt
- Randomized Plain Text
- MapType: rnd, MapSource: Path to a file
This is identical to the Standard Plain Text variant above but with a special post-processing feature. After looking up a value it is parsed according to the contained horizontal bar ( | ) characters which mean "or". In other words, the horizontal bars indicate a set of alternatives from which the actual returned value is randomly chosen. This feature was designed for load balancing in a reverse proxy situation where the looked up values are server names.
File example:
## ## map.txt -- rewriting map ## static www1|www2|www3|www4 dynamic www5|www6
Directive example:
RewriteMap servers rnd:/path/to/file/map.txt
- Internal Function
- MapType: int, MapSource: Internal Apache function
The following internal functions are valid:
- toupper
- Converts the looked up key to all upper case.
- tolower
- Converts the looked up key to all lower case.
- escape
- Translates special characters in the looked up key to hex-encodings.
- unescape
- Translates hex-encodings in the looked up key back to special characters.
- The MapName parameter is the name of the map and is used
to specify a mapping-function for the substitution strings of a rewriting
rule via one of the following constructs:
The RewriteMap directive can occur more than once. For each mapping function use one RewriteMap directive to declare its rewriting mapfile. While you cannot declare a map in a per-directory context, it is possible to use this map in a per-directory context.
RewriteOptions
Module: mod_rewrite | |
Syntax: RewriteOptions Option | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: RewriteOptions inherit |
The RewriteOptions directive sets some special options for the current per-server or per-directory configuration.
- Parameter: Option
- The Option parameter strings can be one of the following:
- This forces the current configuration to inherit the configuration of the parent. In per-virtual-server context this means that the maps, conditions and rules of the main server are inherited. In per-directory context this means that conditions and rules of the parent directory's .htaccess configuration are inherited.
- This forces a request to terminate after reaching a maximum number of redirects and responds with a 500 Internal Server Error. The number parameter value is the maximum number of redirects allowed. This prevents endless loops of internal redirects issued by per-directory RewriteRules. If additional internal redirects are required, increase the default to the desired value. For example, RewriteOptions MaxRedirects=13.
RewriteRule
Module: mod_rewrite | |
Syntax: RewriteRule pattern substitution [flags] | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: RewriteRule ^/ABC(.*) /def$1 [PT] |
The RewriteRule directive is the real rewriting workhorse. The directive can occur more than once. Each directive then defines one single rewriting rule. The definition order of these rules is important, because this order is used when applying the rules at run-time.
- Parameter One: pattern
- The pattern parameter can be an extended regular expression which gets applied to the current URL. Here ``current'' means the value of the URL when this rule gets applied. This may not be the originally requested URL, because any number of rules may already have matched and made alterations to it. See Environment variables set by HTTP Server for more information.
- Additionally in mod_rewrite the not character ('!') is a possible pattern prefix. This gives you the ability to negate a pattern; to say, for instance: ``if the current URL does not match this pattern''. This can be used for exceptional cases, where it is easier to match the negative pattern, or as a last default rule.
- Parameter Two: substitution
- The substitution parameter is the string which is substituted for (or replaces) the original URL for which Pattern matched. Beside plain text you can use back-references $N to the RewriteRule pattern, back-references %N to the last matched RewriteCond pattern, server-variables as in rule condition test-strings (%{VARNAME}) and mapping-function calls (${mapname:key|default}).
- Back-references are $N (N=0..9) identifiers which will be replaced by the contents of the Nth group of the matched Pattern. The server-variables are the same as for the TestString of a RewriteCond directive. The mapping-functions come from the RewriteMap directive and are explained there. These three types of variables are expanded in the order of the above list. As already mentioned above, all the rewriting rules are applied to the Substitution (in the order of definition in the config file). The URL is completely replaced by the Substitution and the rewriting process goes on until there are no more rules unless explicitly terminated by a L flag - see below.
- There is a special substitution string named '-' which means: NO substitution. It is useful to provide rewriting rules which only match some URLs but do no substitution, for example, in conjunction with the C (chain) flag to be able to have more than one pattern to be applied before a substitution occurs.
Remember, an unconditional external redirect to your own server will not work with the prefix http://thishost because of this feature. To achieve such a self-redirect, you have to use the R-flag (see below).
- Parameter Three: flags
- The flags parameter can additionally be set to special
[flags] for Substitution by appending [flags] as the third argument
to the RewriteRule directive. Flags is a comma separated list of the
following flags:
- redirect|R [=code]
- Prefix Substitution with http://thishost[:thisport]/ (which makes
the new URL a URI) to force a external redirection. If no code is
given an HTTP response of 302 (MOVED TEMPORARILY) is used. If you
want to use other response codes in the range 300-400 just specify
them as a number or use one of the following symbolic names: temp
(default), permanent, seeother. Use it for rules which should canonicalize
the URL and give it back to the client, for example, translate ``/~''
into ``/u/'' or always append a slash to /u/user, etc. Note: When you use this flag, make sure that the substitution field is a valid URL. If not, you are redirecting to an invalid location! And remember that this flag itself only prefixes the URL with http://thishost[:thisport]/, rewriting continues. Usually you also want to stop and do the redirection immediately. To stop the rewriting you also have to provide the 'L' flag.
- forbidden|F
- This forces the current URL to be forbidden, for example, it immediately sends back an HTTP response of 403 (FORBIDDEN). Use this flag in conjunction with appropriate RewriteConds to conditionally block some URLs.
- gone|G
- This forces the current URL to be gone, for example, it immediately sends back an HTTP response of 410 (GONE). Use this flag to mark pages which no longer exist as gone.
- proxy|P
- This flag forces the substitution part to be internally forced
as a proxy request and immediately (for example, rewriting rule processing
stops here) put through the proxy module. You have to make sure
that the substitution string is a valid URI (for example, typically
starting with http://hostname) which can be handled by HTTP Server
proxy module. If not you get an error from the proxy module. Use this
flag to achieve a more powerful implementation of the ProxyPass directive,
to map some remote stuff into the name space of the local server. Note: To use this functionality make sure you have the proxy module loaded into your HTTP Server configuration (for example, via LoadModule directive).
- last|L
- Stop the rewriting process here and don't apply any more rewriting rules. (This corresponds to the Perl last command or the break command from the C language.) Use this flag to prevent the currently rewritten URL from being rewritten further by following rules. For example, use it to rewrite the rootpath URL ('/') to a real one, for example, '/e/www/'.
- next|N
- Re-run the rewriting process (starting again with the first rewriting rule). Here the URL to match is again not the original URL but the URL from the last rewriting rule. (This corresponds to the Perl next command or the continue command from the C language.) Use this flag to restart the rewriting process, for example, to immediately go to the top of the loop. But be careful not to create an infinite loop.
- chain|C
- This flag chains the current rule with the next rule (which itself can be chained with the following rule, etc.). This has the following effect: if a rule matches, then processing continues as usual, for example, the flag has no effect. If the rule does not match, then all following chained rules are skipped. For instance, use it to remove the ``.www'' part inside a per-directory rule set when you let an external redirect happen (where the ``.www '' part should not occur).
- type|T=MIME-type
- Force the MIME-type of the target file to be MIME-type. For instance, this can be used to simulate the mod_alias directive ScriptAlias which internally forces all files inside the mapped directory to have a MIME type of ``application/x-httpd-cgi''.
- nosubreq|NS
- This flag forces the rewriting engine to skip a rewriting rule if the current request is an internal sub-request. For instance, sub-requests occur internally in HTTP Server when mod_include tries to find out information about possible directory default files (index.xxx). On sub-requests it is not always useful and even sometimes causes a failure if the complete set of rules are applied. Use this flag to exclude some rules. Whenever you prefix some URLs with CGI-scripts to force them to be processed by the CGI-script, the chance is high that you will run into problems (or even overhead) on sub-requests. In these cases, use this flag.
- nocase|NC
- This makes the Pattern case insensitive, for example, there is no difference between AZ and AZ when Pattern is matched against the current URL.
- noescape|NE
- This flag prevents mod_rewrite from applying the usual URI escaping rules to the result of a rewrite. Ordinarily, special characters (%', '$', ';',) will be escaped into their hexcode equivalents ('%25', '%24', and '%3B', respectively); this flag prevents this from happening. This flag allows percent symbols to appear in the output, as in RewriteRule /foo/(.*) /bar?arg=P1\%3d$1 [R,NE] which would turn '/foo/zed' into a safe request for '/bar?arg=P1=zed'.
- qsappend|QSA
- This flag forces the rewriting engine to append a query string part in the substitution string to the existing one instead of replacing it. Use this when you want to add more data to the query string via a rewrite rule.
- passthrough|PT
- This flag forces the rewriting engine to set the URI field of
the internal request_rec structure to the value of the filename field.
This flag is used to be able to post-process the output of RewriteRule
directives by Alias, ScriptAlias, Redirect, etc. - directives from
other URI-to-filename translators. A trivial example to show the semantics:
If you want to rewrite /ABC to /def via the rewriting engine of mod_rewrite
and then /def to /ghi with mod_alias:
RewriteRule ^/ABC(.*) /def$1 [PT] Alias /def /ghi
If you omit the PT flag then mod_rewrite will do its job fine, for example, it rewrites uri=/ABC/... to filename=/def/... as a full API-compliant URI-to-filename translator should do. Then mod_alias comes and tries to do a URI-to-filename transition which will not work.
Note: You have to use this flag if you want to intermix directives of different modules which contain URL-to-filename translators. The typical example is the use of mod_alias and mod_rewrite.
- skip|S=num
- This flag forces the rewriting engine to skip the next num rules in sequence when the current rule matches. Use this to make pseudo if-then-else constructs: The last rule of the then-clause becomes skip=N where N is the number of rules in the else-clause. (This is not the same as the 'chain|C' flag.)
- env|E=VAR:VAL
- This forces an environment variable named VAR to be set to the value VAL, where VAL can contain regexp backreferences $N and %N which will be expanded. You can use this flag more than once to set more than one variable. The variables can be later dereferenced in many situations, but usually from within SSI (via <!--#echo var="VAR"-->) or CGI (for example $ENV{'VAR'}). Additionally you can dereference it in a following RewriteCond pattern via %{ENV:VAR}. Use this to strip but remember information from URLs.
- The flags parameter can additionally be set to special
[flags] for Substitution by appending [flags] as the third argument
to the RewriteRule directive. Flags is a comma separated list of the
following flags:
Possible substitution combinations and meanings:
Given rule | Resulting substitution |
---|---|
^/somepath(.*) otherpath$1 | not supported |
^/somepath(.*) otherpath$1 [R] | not supported |
^/somepath(.*) otherpath$1 [P] | not supported |
^/somepath(.*) /otherpath$1 | /otherpath/pathinfo |
^/somepath(.*) /otherpath$1 [R] | http://thishost/otherpath/pathinfo via external redirection |
^/somepath(.*) /otherpath$1 [P] | not supported |
^/somepath(.*) http://thishost/otherpath$1 | /otherpath/pathinfo |
^/somepath(.*) http://thishost/otherpath$1 [R] | http://thishost/otherpath/pathinfo via external redirection |
^/somepath(.*) http://thishost/otherpath$1 [P] | not supported |
^/somepath(.*) http://otherhost/otherpath$1 | http://otherhost/otherpath/pathinfo via external redirection |
^/somepath(.*) http://otherhost/otherpath$1 [R] | ^/somepath(.*) http://otherhost/otherpath$1 [R] |
^/somepath(.*) http://otherhost/otherpath$1 [P] | http://otherhost/otherpath/pathinfo via internal proxy |
^localpath(.*) otherpath$1 | /somepath/otherpath/pathinfo |
^localpath(.*) otherpath$1 [R] | http://thishost/somepath/otherpath/pathinfo via external redirection |
^localpath(.*) otherpath$1 [P] | not supported |
^localpath(.*) /otherpath$1 | /otherpath/pathinfo |
^localpath(.*) /otherpath$1 [R] | http://thishost/otherpath/pathinfo via external redirection |
^localpath(.*) /otherpath$1 [P] | not supported |
^localpath(.*) http://thishost/otherpath$1 | /otherpath/pathinfo |
^localpath(.*) http://thishost/otherpath$1 [R] | http://thishost/otherpath/pathinfo via external redirection |
^localpath(.*) http://thishost/otherpath$1 [P] | not supported |
^localpath(.*) http://otherhost/otherpath$1 | http://otherhost/otherpath/pathinfo via external redirection |
^localpath(.*) http://otherhost/otherpath$1 [R] | http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant) |
^localpath(.*) http://otherhost/otherpath$1 [P] | http://otherhost/otherpath/pathinfo via internal proxy |
If you wanted to rewrite URLs of the form / Language /~ Realname /.../ File into /u/ Username /.../ File . Language, you would take the rewrite mapfile from above and save it under /path/to/file/map.txt. Then we only have to add the following lines to HTTP Server configuration file:
RewriteLog /path/to/file/rewrite.log
RewriteMap real-to-user txt:/path/to/file/map.txt
RewriteRule ^/([^/]+)/~([^/]+)/(.*)$ /u/${real-to-user:$2|nobody}/$3.$1