Using virtual aliases
Aside from the normal functions you'd expect from a moderm
404 script,
such as responding to requests for missing resources with 301 and 302 redirects, 410s
for removed resources and so on it's also possible to give one of your pages an alias
so you can refer to it by a shorter or more practical name.
If you just want the technical details on setting up a virtual alias then you can read
about implementing them in the
online editor guide and
the
inline commands guide.
What are aliases?
Virtual aliases or
aliases are just a name that seemed to suit the
technique we were using which used
Server.Transfer calls to execute
a script as if it were an include. If you're wondering what the difference is
between using an alias, using redirects or using
rewrites
then read on.
Aliases are a little like having multiple physical copies of a page, except
rather than having real pages cluttering up your site they're virtual pages.
Aliased pages are really well suited to masking an original script filename with
a vanity filename for technical reasons (see below).
Redirects appear similar but are technically different - an aliased page actually exists
under its assumed name, so if you request it you are physically given that page. A
redirect is a pointer from one page to another, so if you request it you're returned
a pointer to the other page rather than an actual page.
Admittedly it's a
very fine line and sometimes redirects are sufficient - however
there are times when you actually want to create the appearance of a second physical
page which is when you should be using an alias.
Rewrites at a script-level are more powerful and more flexible, but also far more
involved as they're aimed at creating a near-infinite number of pages based on user
input rather than just masking a single page under another name/alias.
What uses are there for aliases?
In a nutshell - anywhere you want to have a physical copy of a page availabe under
another name of your choice, even if that filename wouldn't normally be able to
be used for running your script.
If you just want to point
a person at
page A and have them delivered
to
page B then use a redirect - it's cleaner and more efficient and as far
as a user is concerned they'll not notice the difference between a basic redirect
and an alias.
Personally I've used aliases to mask filenames here and there. Sometimes for
presentation issues where I want to allow someone to right-click and save the
output of an
.asp page as
.htm and don't want to explain why they
need to change the name before they save. Other times I've use it to overcome
a particular browser or other software issue, for example delivering XML content
via ASP causes problems in IE and occasionally you run into homebrew software that
will only accept XML with an XML-type filename so it's easier for me to alias
my ASP-based XML feeds to a .xml or .rss filetype.
The limitations
Well the first limitation is because we're forced to use a
Server.Transfer
method to run the original copy of the document, which means the original needs
to be a filetype that can be parsed & executed by the server. There are two
main ways around this; you can just rename the original to a filetype which can
be parsed, or you can modify IIS so that it will parse your current filetype.
The second limitation is also a result of using a
Server.Transfer
method - the original document name cannot include any querystring information
because
Server.Transfer doesn't support them. There are no real
workarounds for this
Further Reading
If you're still interested in setting up your own virtual aliases then the technical
details are available in the
online editor guide and
the
inline commands guide depending on which setup
you are using. Information about enabling
rewrites
is also available.