mod_rewrite
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
Table 7–6 Request Redirection
Request for
/demo1/happy.html
/demo1/go.jpg
/demos1/lucky.jpg
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.
7-58 Oracle HTTP Server Administrator's Guide
7–6.
Module mod_rewrite in the Apache Server
See Also:
documentation.
Redirected to
/alldemos/happy.html
/alldemos/go.jpg
/alldemos/lucky.jpg
Need help?
Do you have a question about the HTTP Server B12255-01 and is the answer not in the manual?
Questions and answers