09-23-2011
11:56 AM
- last edited on
11-15-2011
08:31 AM
by
mgyles
(Originally posted March 21, 2011)
About this extension
When you move content around a web site, links break. Even if you've patched up all your internal links, site visitors from external links, outdated search results and people's bookmarks will be broken and return a '404 Not Found' error.
This extension intercepts any 404 errors from your web servers and performs the following actions:
For example, if a user tries to access the (missing) page http://example.com/foo/bar/wibble.html, the extension will automatically prompt his browser to try /foo/bar, /foo and ultimately / until it gets a suitable response.
For more information, please refer to the article ‘No more 404 Not Found...?’
This extension has been tested against Zeus Traffic Manager 7.1, and should function without problems with most earlier releases of Zeus Traffic Manager.
Download the extension and extract the 404capture.zts TrafficScript rule. Open in an editor, and paste the contents into a new response rule:
Verify that the extension is functioning correctly by trying to access a page through the traffic manager that would normally give a ‘404 Not Found’ error message, such as http://your.site.com/this/does/not/exist.html.
For reference, the source of the 404capture.zts rule is replicated below:
if( http.getResponseCode() != 404 ) break;
# We have a 404 - how will we handle it?
$path = http.getPath();
string.regexmatch( $path, '.*(\.[^/]*)$' );
$ext = $1;
# If it's an image request, send an empty gif
if( $ext == ".gif" || $ext == ".jpg" || $ext == ".jpeg" || $ext == ".png" ) {
http.sendResponse( "200 OK", "image/gif",
"GIF89a\x01\x00\x01\x00\x80\xff\x00\xff\xff\xff\x0 0\x00\x00\x2c\x00\x00\x00\x00\x01\x00\x01\x00\x00\ x02\x02\x44\x01\x00\x3b",
"" );
}
# if it's an HTML or index file, work up the URL tree
if( $ext == ".html" || $ext == ".htm" || $ext == "" ) {
# If we're on the home page, there's nothing further we can do
if( $path == "/" ) break;
if( string.endsWith( $path, "/" ) ) $path = string.drop( $path, 1 );
$i = string.findr( $path, "/" );
$path = string.substring( $path, 0, $i-1 )."/";
http.redirect( $path );
}
# otherwise, it's some other sort of media (css, js, video etc) so just
# send a bare '404' response
http.sendResponse( "404", "text/plain", "", "" );
Download this extension below:
© Copyright 2012 Riverbed Technology. All rights reserved Riverbed.com | Contact Us | Technical Support | Terms & Conditions | Privacy Policy