URL Aliaser
XML Menu Builder
Build powerful, client-side DHTML menus using XML for data and CSS for style. No JavaScript data! No having to place list elements on every single page of your website! No plug-ins!

URL Aliaser is a JavaScript script that allows you to specify any URL by alias name. The alias name is supplied as a parameter to a physical URL.

For example, this page uses URL Aliaser to associate the alias example with the URL http://example.com

This enables users to reach the URL http://example.com, by clicking on the following link:

http://codehouse.com/javascript/scripts/url_aliaser/?alias=example

If you click the link above, what will happen is that first this page gets loaded, and then this page will redirect you to http://example.com.

URL Aliaser is useful for people who list their URLs at other websites, but are often changing the names or location of the URLs they've already listed. By using URL Aliaser, you can supply to others an alias for a URL. The aliased URL you give people will always lead to the desired URL you want people to go to. To the outside world, the aliased URL is a fixed, permanent address. But internally, you can easily update the physical URL you want people to be redirected to.

The format for associating a URL with an alias is as follows:

myURL?alias=myAliasToAnotherURL

Where myURL is any URL, and myAliasToAnotherURL is the alias you've chosen to associate with another URL that you would like to be redirected to.

No web server is required to run URL Aliaser. It is portable, light-weight, highly configurable, and best of all, it's free!

Browsers Tested on

  • Internet Explorer/Windows 5.0+
  • Internet Explorer/Mac 5.0+
  • Netscape 6.0+
  • Mozilla 1.0+
  • Opera 7.0+
  • Safari 1.0+

Download URL Aliaser Script and Demos

Download url_aliaser.zip

Configuration Instructions

Step 1

Before using the source code, make sure that you read and agree to the terms of the License Agreement, which will open in a separate window.

Step 2

Download the file url_aliaser.zip to your computer and unzip it. url_aliaser.zip contains the following files:

urlAliaser.js
demo.htm

urlAliaser.js is the script that runs the program. demo.htm is a demo file that uses the script. You're free to modify demo.htm for your own personal use. This is probably the easiest way to get started.

Step 3

Create an HTML file in the same directory as the one you just unzipped the contents of url_aliaser.zip to. We will refer to this HTML file as the Target Page. Instead of creating a new Target Page, you can use a preexisting HTML file. Open the Target Page in an editor and place the following script tag pair between the opening and closing <head></head> tags.

<script src="urlAliaser.js" type="text/javascript"></script>

We strongly recommend that you place this above another other tags within the <head> tag block, as this will avoid unnecessary parsing of your webpage and speed up redirection time.

Step 4

Immediately under the script tag you entered in the previous step, create a script block:

<script type="text/javascript">

</script>

Inside this script block, you will need to supply the JavaScript code to create a UrlAliaser object.

For people that have no experience at all with JavaScript or programming, don't panic: We've provided UrlAliaser Object Maker. This is an online tool that generates a UrlAliaser object for you.

The UrlAliaser class constructor takes one parameter, which is a multidimensional dimensional array. Specifically, it is an array of arrays with two indexes: The left index describes the alias, and the right index describes the URL associated with the alias. This should become self-evident when you see the example code below.

Here is the call to create a UrlAliaser, used for this page:

<script type="text/javascript">
new UrlAliaser([
   ["example", "http://example.com"],
   ["microsoft", "http://microsoft.com"],
   ["ibm", "http://ibm.com"]
]);
</script>

Once we have included the urlAliaser.js script, as mentioned in the previous step, the above UrlAliaser object allows us to alias the following URLs:

http://codehouse.com/javascript/scripts/url_aliaser/?alias=example

http://codehouse.com/javascript/scripts/url_aliaser/?alias=microsoft

http://codehouse.com/javascript/scripts/url_aliaser/?alias=ibm

Here is a stripped-down version of what the <head> tag of this page looks like. All the code needed to alias URLs is provided:

<head>

<script src="urlAliaser.js" type="text/javascript"></script>

<script type="text/javascript">
new UrlAliaser([
   ["example", "http://example.com"],
   ["microsoft", "http://microsoft.com"],
   ["ibm", "http://ibm.com"]
]);
</script>

</head>

Step 5:

Upload the Target Page and urlAliaser.js to your web server, and place them in the same directory.

That's it! You should be ready to start URL aliasing away.

If you have any questions, find any bugs, or have suggestions, feel free to contact us.

Caveats

  • Internet Explorer for the Mac doesn't process parameterized URLS that don't explicitly identify a filename, unless a "/" character is placed before the question mark. For example, don't use the following syntax:

    http://codehouse.com?alias=urlAliaser

    Instead, precede the "?" character with a "/" character like this:

    http://codehouse.com/?alias=urlAliaser

  • At the time of this writing, the current version of Safari — 1.0, performs the redirection correctly, but parses some, if not all of the web page before it redirects. This makes the operation slow and visually jarring. This is yet another example of how immature and not-ready-for-prime time Apple's Safari is.

  • Unlike the domain name, the URL alias is case sensitive.

  • Make sure to explicitly enter the resource type of the URL to redirect to. The resource type is the part before the initial ":". For example, don't use codehouse.com. Instead use http://codehouse.com

UrlAliaser Object Maker

This is a tool that generates the JavaScript source code for a UrlAliaser object. A UrlAliaser object is required in order to configure this script. See Step 4 for more information.

Usage information is available in a separate help window. You can get targeted information about specific parts of this tool by clicking on the help images below.

help Alias Name:( Example: urlAliaser)

help URL: ( Example: http://codehouse.com )

help

help Aliased URL List:

help UrlAliaser Object:
help help