Corporation Server User Manual

mod_rewrite
7-58 Oracle HTTP Server Administrator’s Guide
If there was a request for /demo1/not_just_index.html, all the preceding
rewrite rules would have redirected the request the request to
/alldemos/index.html, that may not be what you want. It is quite possible that
you may want to redirect to the corresponding files in /alldemos, as listed in
Table 7–6.
Then you have to use substitution in your rewrite rule as follows:
RewriteRule ^/demos1(.*)$ //alldemos/$1 [R NC]
The explanation for this rule is:
Take the value of the expression, such as happy.html, go.jpg, and lucky.jpg,
that appears after demo1 as variables ($1) and substitute it after /alldemos/.
Redirection Examples
For redirecting requests from the DocumentRoot to a directory called newroot, set
the following mod_rewrite directives:
RewriteEngine On
RewriteRule ^/(.*)$ /newroot/$1 [R]
For directing requested for files from one directory (olddir) to another (newdir),
set the following directives:
RewriteEngine On
RewriteRule ^/olddir(.*)$ /newdir/$1 [R]
In each of these cases, you should ensure that the requested resources are indeed
available in the redirected location. The mod_rewrite module does not ensure the
existence of the requested resource in the new location.
Table 7–6 Request Redirection
Request for Redirected to
/demo1/happy.html /alldemos/happy.html
/demo1/go.jpg /alldemos/go.jpg
/demos1/lucky.jpg /alldemos/lucky.jpg
See Also: Module mod_rewrite in the Apache Server
documentation.