Aliases


Mapping a URL-Path to a Different Location

The main purpose of an alias is to re-route a browser's request from one location to another. The new location can be just a different directory on the current server or it could be a complete URL to a different server.

Using the command WRKWWWALS, a list of aliases and the values that they should be mapped to are configured. The server checks every URL-path to see if an alias substitution should occur. If the URL-path begins with an alias, the value the alias is mapped to replaces the aliased portion of the URL-path and appends the end portion of the URL-path to the new URL-path. The replaced portion can be the first directory, the first several directories, the whole URL-path, or any beginning portion of a URL-path. Note that Web Server/400 supports begins with alias matching. This means that the only time an alias substitution occurs is when the beginning of a URL-path matches a configured alias. This comparison is case-insensitive.

Alias Examples

In this example, assume the following aliases have been configured, the Default Source Type is Root, and the Index Name is index.html.

/abcdef/
maps to /xyz/

/one/two/three/
maps to /four/five/

/pop
maps to /soda

/popcorn
maps to /corn

With this setup, each of the following requests would be handled as described.

A URL-path of /AbCdEf/webpage.html
The server would accept this request and return the file /xyz/webpage.html.

A URL-path of /one/two/three/
The server would accept this request and return the file /four/five/index.html. The index.html is placed at the end since this is the default Web document for all directories. This would only be returned if it existed in /four/five/. Otherwise, a dynamic index of /four/five/ would be returned.

A URL-path of /popcornball/promo.gif
Since the server does a maximal match on alias names, the server would return /cornball/promo.html. The /popcorn portion was mapped to /corn and the remaining portion of the URL-path, ball/promo.gif was appended to that.


Using Aliases to Access Other File Systems

Aliases are also used to indicate which file system a URL-path resides on. Each alias can have an associated type with it, the Alias Source Type. Using this, any requested URL-path can be mapped to a directory in any file system.

Examples of Aliases and Other File Systems

In this example, assume the following aliases have been configured, the Default Source Type is QDLS, Document Root is set to /webpages, and Document Root QDLS is set to /qdls/webpages.

/native/
maps to /library1/ in QSYS.

/images/
maps to /images/ in Root.

/info
maps to /data with no specified file system.

With this setup, each of the following requests would be handled as described.

A URL-path of /native/webpage.html
The file webpage in library library1 would be served out of QSYS as an HTML file.

A URL-path of /images/dog.jpg
The file /webpages/images/dog.jpg would be returned.

A URL-path of /info/cat.html
The file /qdls/webpages/data/cat.htm would be returned. Notice that the filename was converted to an 8.3 format since this request was served from QDLS.


Using Aliases to Access Special Web Documents

In addition to mapping URL-paths from one location to another, aliases are used to indicate that a URL-path should reference a special Web document type. Three special types are supported: Webulator/400 Applications, USF Objects, and Spooled Files.

Webulator/400 Applications
Webulator/400 applications are accessed by creating an alias with a Source Type of *WEBULATOR. Then, any URLs that begin with this alias are handled by the Webulator/400 feature of Web Server/400. Everything that occurs after the alias defines the application configuration to run.

For example, if /WEBULATOR maps to /WIDGET with a source type of *WEBULATOR then asking for the URL /WEBULATOR/ORDER would cause Webulator/400 to use the configuration values setup for the directory /*META/WEBULATOR/WIDGET/ORDER.

USF Objects
USF Objects can be accessed through Web Server/400. This access is opened up by specifying an alias that is has a Source Type of *USFOBJ. Then, any URL-path that begins with this alias will be treated as a URL that references a USF Object. When configuring USF Object aliases, the value that the alias maps to should not be specified.

Spooled Files
An alias is used to indicate a URL-path references a Spooled File. A URL-path that begins with an alias that has a Source Type of *SPLF indicates that the URL-path references an AS/400 spooled file. When configuring Spooled File aliases, the value that the alias maps to should not be specified.


Using Aliases to Redirect URLs to Different Servers

A Web server has the ability to tell a Web browser to look for a URL at a certain location on an entirely different Web server. This is referred to as Redirection. This might be useful if a Web document or a set of Web documents are removed from one server, and relocated to another. Existing HTML documents with links to the old documents will still work since the server will redirect them automatically to the new location. Also, people that have a URL in their quicklist will still be able to find Web documents that have moved.

URL redirections can be permanent or temporary:

Permanent
The new URL will be in effect indefinitely and it is not planned to have the old URL be valid anymore.
Temporary
The redirection is only temporary. The old URL will be effective again or the redirection could change to something else at any time.
When redirecting a URL-path the entire new URL must be specified. This includes the protocol, server, port, and URL-path.

Examples of Alias Redirection

In this example, assume the following aliases have been configured, the Default Source Type is QDLS, Document Root is set to /webpages, and Document Root QDLS is set to /qdls/webpages.

/xyz/
maps to http://new.server.com:5000/xyz/ (permanently).

/abc/
maps to http://new.server.com/ (temporarily).

With this setup, each of the following requests would be handled as described.

A URL-path of /xyz/webpage.html
The server would send back a response to the browser indicating that this URL has moved permanently to http://new.server.com:5000/xyz/webpage.html.

A URL-path of /abc/webpage.html
The server would send back a response to the browser indicating that this URL has moved temporarily to http://new.server.com/webpage.html.


Alias Matching

These are some important points regarding aliases that you should know prior to setting up aliases.

Begins-with match
A check is only made to see if a URL-path matches an alias from the very beginning of the URL-path. An alias that appears in the middle or at the end of a URL-path is ignored.

Leading slash
All aliases should begin with a slash since all URL-paths begin with a slash. If the alias did not have a leading slash, it would never be found in a URL-path because only begins-with matching is done with aliases.

Maximal matching
If two aliases that begin the same are defined, the server has to decide which alias substitution to use on a URL-path that begins the same as both aliases. The server always uses the longest alias that still matches. For example, if an alias /abc maps to /uvw and alias /abcdef maps to /xyz and the URL-path /abcdef/web.html is requested, the server has to decide if this should be converted to /uvwdef/web.html or /xyz/web.html. Web Server/400 does a maximal match which means that the longest matching alias will always be picked. In this example, /xyz/web.html would be used since it comes from the longest matching alias (/abcdef).

Trailing slashes
You should avoid having an alias without a trailing slash point to a directory with a trailing slash. If an alias is setup like this, any references within the resulting page will not work since the browser will not know that the resulting page is a directory. For example, if you have an alias /xyz mapped to /abc/, and a browser requests /xyz, a dynamic index of /abc/ will be shown. If the user then selects a file from within the dynamic index, the browsers will make that selection relative to / rather than /xyz/ since to the browser, the original request was for a file not a directory.

Aliasing one HTML document to another
Having an alias that maps one HTML file to an HTML file in a different directory will work but all embedded links within the resulting HTML document will be relative to the directory of the original URL rather than to the directory where the HTML file was actually found. For example, assume the alias /company/homepage.html maps to /branch/index.html and that /branch/index.html contains the embedded image logo.gif which resides in the /branch subdirectory. If a browser requests /company/homepage.html, the server will return /branch/index.html as expected, but the embedded image will not be found since the browser will try to load it from the server with the URL /company/logo.gif rather than the desired URL /branch/logo.gif. To get around this, create an alias that maps /company/ to /branch/. The server then maps all requests to the new directory.