Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change 
notification.

The following page has been changed by noodl:
http://wiki.apache.org/httpd/Rewrite/VirtualHandler

The comment on the change is:
Rough outline

New page:
Perhaps the most frequently asked rewrite question seen on #apache involves 
mapping arbitrary URIs to a handler script or proxy URL. There are several 
variations on this theme, detailed below.

The technique of mapping all but a few URI patterns to a handler can be used to 
delegate the process of URI translation to a more capable programming 
environment than is provided by mod_rewrite. It is easier to parse e.g. 
''/books/history/french_revolution'' with a scripting language than with a set 
of depth-limited patterns, for example.

The rules shown here are designed to work in !VirtualHost context. For 
information on translating them for .htaccess context, see 
[:Rewrite/Context:Context]

=== Map any request to a handler ===

In the case where all URIs should be sent to the same place (including 
potentially requests for static content) the method to use depends on the type 
of the handler. For cgi scripts, use:

{{{
ScriptAliasMatch .* /var/www/script.cgi
}}}

For other handlers such as php scripts, use:
{{{
<Location />
 Action foo-action /script.php virtual
 SetHandler foo-action
</Location>
}}}

Note that the above requires version 2.2+

=== Map URIs corresponding to existing files to a handler instead ===
{{{
<Location />
 Action foo-action /script.php
 SetHandler foo-action
</Location>
}}}

=== Map all URIs except those corresponding to existing files to a handler ===
{{{
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule (.+) /script.php
}}}

Reply via email to