Creating and managing inline rules
This page is part of the extended installation guide for our
smart 404
management script and deals with creating and managing inline rules & redirects -
there's also a version of this document for the database driven modules which support
rule creation and management via the
online editor.
The most recent release of this script can be downloaded from the projects
main page.
Below you'll find documentation for each of the rules and redirects, explaining
expected inputs and the sort of results you'd expect. If you're looking for
working examples then the best place to check is the
Redirect_LoadRules( ... )
function included with the default
custom404-inline.asp as
it contains examples of each function with a variety of setups on display.
Permanent Redirects - 301
This type of redirect is normally used when a page or similar resource has
been moved from a location on your website to another location or a different
website and you want everyone to use the new location instead of the old
one from this point onwards.
How to create a 301 redirect
You need to add the following code to
custom404-inline.asp
in the
Redirect_LoadRules( ... ) function;
Redirect_Add "URL A", "URL B", "PERM", sRules
What does that do? Well
URL A is a reference
to
something on your site, relative to the root folder on the website.
When someone requests a resource matching that string they'll be fed a 301
redirect to
URL B which can be another reference
similar to the first or an absolute URL pointing to your own website or an
external website.
Temporary Redirects - 302
This type of redirect is normally used when a page or similar resource has
been temporarily moved from it's normal location and/or you might still want
people to come back to this location in the future rather than going directly
to the new location in future as they would with a permanent redirect.
How to create a 302 redirect
You need to add the following code to
custom404-inline.asp
in the
Redirect_LoadRules( ... ) function;
Redirect_Add "URL A", "URL B", "TEMP", sRules
What does that do? Well
URL A is a reference
to
something on your site, relative to the root folder on the website.
When someone requests a resource matching that string they'll be fed a 302
redirect to
URL B which can be another reference
similar to the first or an absolute URL pointing to your own website or an
external website.
Permanently Removed / Gone - 410
This is one step up from a 404, which is the equivalent of saying "I can't
find what you requested, I don't know what's happened to it". On the other
hand using a 410 or "Gone" response is a definite response to that request,
in effect saying "Whatever you requested doesn't exist on this server anymore
and wont be replaced in the future".
How to create a 410 response
You need to add the following code to
custom404-inline.asp
in the
Redirect_LoadRules( ... ) function;
Redirect_Add "URL A", "", "GONE", sRules
What does that do? Well
URL A is a reference
to
something on your site, relative to the root folder on the website.
When someone requests a resource matching that string they'll be fed a response
with HTTP status code 410.
Access Denied - 403
Now and again you'll find you want to respond with a deny to a certain request
normally as a subtle hint to the whatever is requesting the resource that they
shouldn't bother. Also helps create
cleaner logs by filtering out junk
requests at the source meaning your site statistics should be a little easier
to read.
How to create a 403 response
You need to add the following code to
custom404-inline.asp
in the
Redirect_LoadRules( ... ) function;
Redirect_Add "URL A", "", "DENY", sRules
What does that do? Well
URL A is a reference
to
something on your site, relative to the root folder on the website.
When someone requests a resource matching that string they'll be fed a response
with HTTP status code 403.
Virtual Aliases
Virtual aliases were created to as an extremely simplified and rather ugly cludge
to allow URL aliases to be created so when they request file A they are actually
served file B. They're very useful when you want to have a script appear to be
a different filetype than it really is - for example we use them for delivering
XML and RSS content.
How to create a virtual alias
You need to add the following code to
custom404-inline.asp
in the
Redirect_LoadRules( ... ) function;
Redirect_Add "URL A", "URL B", "VIRT", sRules
What does that do? Well
URL A is the "trigger" URL,
a reference relative to the root folder on the website. When someone requests
a resource matching that string
URL B is executed.
While
URL A can be any path or URL you need it to
be,
URL B needs to be a script or similar piece of
executable code on your website.
For more information read through the
URL aliasing guide
which explains in more details the uses and mechanics of virtual aliases.