DekGenius.com
[ Team LiB ] Previous Section Next Section

Recipe 5.18 Turning Document Names into Arguments

Problem

You want to redirect requests for documents to a CGI script, or other handler, that gets the document names as an argument.

Solution

Use RewriteRule in httpd.conf:

RewriteRule "^/dir/([^./]*)\.html" "/dir/script.cgi?doc=$1" [PT]

Discussion

This solution causes all requests for HTML documents in the specified location to be turned into requests for a handler script that receives the document name as an argument in the QUERY_STRING environment variable.

The PT flag should be included to allow any appropriate subsequent URL rewriting or manipulation to be performed.

See Also

    [ Team LiB ] Previous Section Next Section