For vanity search engine purposes i’ve written a script that re-directs a client request for http://cjbuckley.net/ to http://www.cjbuckley.net/. It’s important to do this so that google has one site index for your site, indeed, google honours 301 permanent re-directs for this very requirement!
The below script is written in Trafficscript language. What’s really useful about this script is that a client request for any URL not pre-fixed by www. is catenated and 301′d back to the server, prepended with the original path request.
# Cache Host header being issued by the client
$host = http.getHeader( "Host" );
# This line passes both the path and query string to $url,
# meaning that a request for /path/to/output?is-here.php
# is placed into the below variable.
$url = http.getRawURL();
# log.info( "url: ".$url ); # Optional log output
# Use a Perl Compatible regular expression to match our domain name.
if( string.regexmatch( $host, "^domain-name$" ) ) {
# Re-write the variable cached in $host to include a prefix of 'www.'
$location = string.regexsub( $host, "domain-name.com", "www . ".$host );
http.sendResponse( "301 Moved Permanently", "text/html", "",
"Location: http://".$location . $url);
}
August 8, 2006



















Sorry, no comments yet.