Previous: CGI Scripts and Programs Contents and Introduction Next: Using the Search Engine

Flexible redirections

Introduction

Redirections of non-existing pages to existing pages can easily be configured within your web site.
This also includes the presentation of the list of available linguistic versions of a page in case the requested version does not exist.

Redirections can be useful to keep active an old addressing scheme. In case of site restructuration, the main parts of the site could be redirected to their equivalent part in the new site.

Various behaviours are available to progressively encourage people to update their bookmarks. It goes from the direct redirection without notification to the display of a page with the non-clickable address of the new site.

Restriction: Only non-existing pages can be redirected by this mean.

How it works

When a non existing page is requested from the server, the webserver calls a program that will analyse what can be done depending on rules set in configuration files.

The program will look for a _redirect.cfg file in the directory of the requested address. If not found, the program will recursively scan the parent directories until it finds a _redirect.cfg file.

The _redirect.cfg file tells the program how to map the requested address to a new address with rules. If none of the rules matches the requested address, the program will try to find a matching rule in the _redirect.cfg of the parent directory tree.

When the first matching rule is found, the program will optionally present a page - based on a template - that will show the requested address and the new computed address. This would help the users to update their bookmarks.

An optional automatic timed redirection can be programmed as well.

Basic redirections

Configuring the _redirect.cfg file

The _redirect.cfg is a text file with rules defined on separated lines.

Each line contains 3 columns representing a rule.

The first column is a regular expression that the program tries to interpret according to the requested address (URL) . If the rule matches the address then the program will redirect the browser to the page given in the second column.

The second column is thus the new address to which the browser will be redirected. This new address should be relative to the directory of the _redirect.cfg file.
It is also possible to specify fully qualified addresses, but then the existence of the page cannot be tested by the tool. This could however be useful to redirect to dynamic applications or to external websites.

The third column is a code that indicates the behaviour of the program:

Sample _redirect.cfg file

Configuring the _redirect[_xx].htm template files

The _redirect[_xx].htm template files are used to present the user with a text showing the requested address that doesn't exists anymore and the new computed address. This should help the user to update locally stored bookmarks.

The _redirect[_xx].htm template files should be placed in the same location as the _redirect.cfg file

You can have one template file per language (_redirect_[xx].htm) and one additional template for non-existing files that doesn't contain a language code in their name (_redirect.htm)

Please note that those template files are not used for linguistic research (code = -999).

The _redirect[_xx].htm template files are standard IPG-compliant HTML files with special comment tags that will be replaced by the program before being sent to the browser:

An optional text can also be placed between the following tags: <!--AUTOTEXT--> and <!--/AUTOTEXT-->. This text will be displayed when an automatic timed redirection is requested.

Sample _redirect_en.htm template file


<HTML>

  <HEAD>

    <TITLE>Page not found</TITLE>

    <BASE HREF="http://europa.eu.int/comm/agriculture/_redirect_en.htm">

  </HEAD>

  <BODY>

  <CENTER><H1>Welcome to the European Commission</H1></CENTER>

  <CENTER><P>The page you have requested:</P>

  <P><!--OLDURL--></P>

  <P>is not available, or has been moved. You should try:</P>

  <P><B><!--NEWURL--></B></P>

  <!--AUTOTEXT-->

   You will be redirected to the new address in a few seconds 

  <!--/AUTOTEXT--></CENTER>

  </BODY>

</HTML>

	

Linguistic redirections

Configuring the linguistic templates (template_lang_xx.htm in the example)

The linguistic template files are used to present the user with a page showing the available/not available linguistic versions of page.

By default, the linguistic template files should be placed in the same directory as the _redirect.cfg file. It is also possible to specify the path of the template files.

You should have one template file per navigation language in your site. This means that the text explaining that the requested linguistic version does not exists will be written in the navigation language.
You can also give a single template file in a default language.

The linguistic template files are standard IPG-compliant HTML files with special comment tags that will be replaced by the program before being sent to the browser:

Please note that only the linguistic versions that have an entry in the template files (<!--LANG NAME="<language>") will be presented in the list of available versions.

Sample linguistic template


<HTML>

  <HEAD>

    <TITLE>Page not found</TITLE>

    <BASE HREF="http://europa.eu.int/comm/agriculture/template_lang_en.htm">

  </HEAD>

  <BODY>

  <CENTER><H1>Welcome to the European Commission</H1></CENTER>

  <P>The page you have requested does not exist in English.</P>

  <!--LANG NAME="es" FOUND="yes"-->please click to access the

 	 <!--LINK-->Spanish<!--/LINK--> version<!--/LANG-->

  <!--LANG NAME="fr" FOUND="yes"-->please click to access the

	 <!--LINK-->French<!--/LINK--> version<!--/LANG-->

  <!--LANG NAME="de" FOUND="yes"-->please click to access the

	 <!--LINK-->German<!--/LINK--> version<!--/LANG-->

  </BODY>

</HTML>

	

Life examples - Demonstrations

The examples are based on a demo subsite with the following content:

demo

Data Centre