Rewriting HTTP requestsIt's sometime necessary to rewrite an HTTP request for one file into another file. For example, part of the content on a website may have been moved, but clients may have cached or bookmarked the old links. Alternatively, a legacy component of a website may use a different URL space to identify resources.
# rewrite all requests for content in /graphics to /images instead
$url = http.getPath();
if( string.startsWith( $url, "/graphics/" ) ) {
$newurl = string.regexsub( $url, "^/graphics/", "/images/" );
http.setPath( $newurl );
}
The above example uses a regular expression substitution to change "/graphics/" to "/images/" in the URL. There are many other ways to manipulate strings; for example, the $newurl = "/images/" . string.skip( $url, 10 );
Owen Garrett
[Zeus Dev Team] 01 July 2005
|
Recent Articles
Other Resources
|


