Zoom Search Engine FAQ - Using Relative Links

Q. What is a Relative Path?

Relative paths refer to file locations based on the current directory. That is, they often refer to locations in the form of “up one directory level” and often begin with one or two dots (“.”). An example would be “../index.html” which would refer to the file “index.html” one directory level up.

A key to relative paths:

  • A single dot (“.”) refers to the current directory, eg. “./test.html” would refer to the file “test.html” in the current directory.
  • Double dots (“..”) refer to the previous directory, eg. “../test.html” would refer to the file “test.html” in the previous directory.
  • To refer to a location which is more than one directory level up, use a combination of double dots, eg. “../../test.html” would refer to a file two directory levels up.

Understanding absolute and relative paths are important to determine the most consistent and effective way of linking to files, and it is required knowledge for all web developers. You can find more information on relative and absolute paths in online web design tutorials.

There is also an Appendix chapter on using relative paths to specify a base URL for CD-ROM distribution in the Zoom Users Guide.

Q. How do I use Relative Links for search results in Spider Mode?

You can configure Zoom to use relative links (as opposed to absolute links) in the search results. In Offline Mode, this can be done by simply specifying a relative path (eg. "./" or "../") as your Base URL.

In Spider Mode, you should not change the Base URL to a relative path. This is because the Base URL is required to determine whether a URL is "internal" or "external" to the site you are indexing. So the base URL should reflect the domain name and location of the pages you wish to crawl with the spider.

By default, Spider Mode will create absolute links for its search results. This means that the links contain the full URL, including the domain name, eg. "http://www.mysite.com/mypage.html".

In some cases however, you may want to use relative links instead of absolute links. Some example scenarios are:

  • If you are creating a set of index files and search page which will be hosted on mirrored websites (sites containing the same content but hosted on different domains). For example, if you have two websites which are identical, but one is hosted at "www.mysite.com.au" and one is hosted at "www.mysite.com".
  • If you are indexing from a development server, but wish to have the same search files work when you move the files over to the live server, without having to re-index the live files.

In either of the above situations, by using relative links, the search index will not be locked to the original URLs of the pages that were indexed using Spider Mode. Instead, they can be linked relative to the location of the search files.

Note that with the second example above, an alternative solution would be to use the "Rewrite Links" feature to change the domain name. For example, you can specify that all files indexed with the URL of "dev.mysite.com" will be rewritten as "www.mysite.com".

To change to relative links, simply setup Spider Mode to index your pages as normal, but before indexing, click on "Configure"->"Indexing Options" and check the option for "Rewrite all indexed URLs as follows". Then specify that all files indexed with the original URL or domain name will be rewritten as a relative path. For example:

Find in URL: http://www.mysite.com/
Replace with: ./

This will change all links in the search results in the form of "http://www.mysite.com/mypage.html" to be "./mypage.html".

Note that with relative links, the most important thing to understand is that the links will now be relative to the location of your search script. So if your search script is hosted at "http://www.mysite.com/search.php" for example, then the above example will be fine.

However, if you have your search script located in a subfolder, for example, "http://www.mysite.com/search/search.php", and you begun your indexing one level above this directory (eg. your start URL is "http://www.mysite.com/"), then you should have a relative path such as "../" so that your links will be in the form of "../mypage.html", etc.

For a further explanation of relative paths, see the FAQ on "What is a Relative Path?"

 

Return to the Zoom Search Engine Support page