WebSTAR 4 Manual & Technical Reference

Manual Contents | Chapter Contents | Previous Page | Next Page

Folder Hierarchy, File Paths, and Names

You can think of your website as a tree, with a main stem or root (the main WebSTAR folder) and branches (subfolders in that folder). We'll refer to these as the WebSTAR root folder and the folder hierarchy . You can use URLs to link to files all the way through the folder hierarchy, and to FTP folders as well.

WebSTAR uses standard Mac folders--they correspond to "directories" on other systems.

Example Hierarchy and File Paths

Our simple example, www.domain.com, has a products folder which includes a widgets subfolder, an ourwork folder (within a security realm), and an FTP folder including a pub folder set up for anonymous access and a widgets folder.

 

The file path is the description of how to find a file within the folder hierarchy. The delimiter is a slash ("/"), which surrounds a folder name.

In this case, you can have HTTP links, with their file paths, that would like this:

See also: Relative and Absolute Links .

File Hierarchy and Virtual Hosting

If you have virtual hosting enabled, you set the virtual host root folder for each of your web site hosts. The folder hierarchy is the same, but instead of starting with the WebSTAR root folder, it starts with the folder that you have designated.

See also: Special Virtual Domain Design Issues .

In the following simple example, the WebSTAR server has two virtual hosts: www.knicknacks.com (root folder is knickknacks ) and the Spanish-language cositas.domain.com (root folder is cositas ).

Virtual Hosts and Subfolders

 

These URLs do not refer to the WebSTAR folder, but to the root folder for that domain.

will display the default file in the knickknacks folder;
will display a specific page in the party subfolder
will display an information page in Spanish

Links to Subfolders and Parent Folders

To refer to a folder, you enter the name with slashes before and after the folder name. For example, this URL:

 
http://www.domain.com/documentation/ws4manual.html

will tell WebSTAR to look inside the Documentation folder for a file called ws4manual.html and serve it back to the browser.

To link to a page in a subfolder within your folder hierarchy, just use the name of the folder. For example, to show a page for your blue widget, make a folder called widgets in the WebSTAR folder, and a file named bluewidget.html in the widgets folder. To access this file, the URL would be:

 
http://www.domain.com/widgets/bluewidget.html

Remember, replace "www.domain.com" with your host name or IP address.

Default Files in Subfolders

When a URL for a folder arrives, WebSTAR will use the default file name that you've specified in the server or virtual host settings pane, as described in Default Names and Virtual Host Options . This applies to all subfolders for each virtual host.

Directory indexing overrides the Default File display: see WebSTAR Directory Indexer .

Relative and Absolute Links

You do not have to know HTML to run WebSTAR, but should understand how file paths and links work. This section helps you visualize the relationships between folders and HTML links.

When you make HTML links to files on your website, you can use absolute paths to link to files always starting from the root level. For example, a file in the widgets folder could refer to an image like this:

 
<A HREF="/images/bluehat.gif">

However, it's often easier for you to use relative paths , linking to files in relation to the HTML page which includes the link. The syntax of the relative addresses is standard UNIX: a slash ("/") means a folder, and two periods (" .. ") means a level up in the folder hierarchy.

If you are using Virtual Domains, you should use relative paths, because some browsers may be confused about the correct root folder.

Examples of Absolute and Relative Links

Here are some examples of both relative and absolute URL links, according to the example hierarchy .

Remember that you can't go above the root folder, even on virtual hosts. However, if you want a file in another virtual host on the same machine, you can link to it using the host name, for example:

<A HREF="www.domain.com/widgets/widget.gif">

Web File and Folder Name Rules

Although WebSTAR is running on your Mac, you still must work within the limits of the Internet and web serving conventions. Unfortunately, this may mean that you must rename or alias some of your files and folders.

For simplicity, you should use standard English letters and numbers in your file names. Hyphens ("-"), periods (".") and dashes ("-") are also fine, but spaces between words must be encoded (see Macintosh Special Characters in File Names ).

You should never include these characters in any file name:

Macintosh Special Characters in File Names

Macintosh Extended characters (option-key characters) are useful and appropriate especially for languages other than English. However, file names in URLs cannot use these characters--the names are limited to the characters you see on the keyboard. Extended characters can cause additional problems. Some proxies and other caches may not be able to resolve URLs if they aren't exactly the same as the file name--they can't convert the encoded characters.

Macintosh Extended ASCII (or special characters ) refer to those characters which you enter with the option key, like "å" and "£".
Hexadecimal (Hex) is the base-sixteen number system used by many computers. ASCII is the name for internal computer codes of letters and numbers.

There are situations when you must use Extended ASCII characters in file names, because they are required for other languages or for scientific clarity. In that case, you must encode the links in HTML documents to these files using the standard Hex numbers for each special character. For example, "20" is the Hex number for space, and "26" is the number for ampersand ("&"). Thus, to link to a file named "my file", you have to use "my%20file", and for "cité ", you must use"cit%8E%20%C4".

Some Mac HTML editors will perform this encoding for you automatically when you select a file and link it. For Hex encoding information, see any Macintosh programming book, the BBEdit ASCII table, or an online list such as:

 
http://developer.apple.com/techpubs/mac/Text/Text-516.html

Redirection: Aliases and Redirect Files

Your web host directory structure does not have to match the actual file organization on your hard drive. For example, you may want to have descriptive default file names in each folder, store your images on another volume, move files without breaking links, or just make URLs simpler to type.

To have the WebSTAR web server redirect a URL from the apparent location to your preferred file, you have to create a file in the correct location and respond to the request appropriately. Standard Mac aliases and special WebSTAR Redirect files give you two simple ways to perform this redirection.

There are also third-party CGIs and Plug-Ins for more global processing: see the Extending WebSTAR page on the StarNine web site for information.

Folder and File Aliases

You can use aliases to link to a file in another folder. The browser will display the URL of the alias, not that of the original file. Aliases are good for creating several apparent URLs that actually refer to one original file, reducing the maintenance problems of keeping files synchronized. In addition, you can make URLs much shorter, by placing a link to the folder farther up in your folder hierarchy.

Aliases also allow you to double-click on the server machine and open the folder or file automatically.

Aliases can also supply file suffixes without renaming the original files. WebSTAR uses the name of the alias for suffix mapping, and then translates the alias to find the original file's contents.

Be careful when using aliases: they require any relative links in HTML to be relative to the alias location , rather than the actual location in the folder hierarchy.

Aliases are particularly useful for storing images on a separate hard drive: create an images folder on the second drive, and make an alias to it in your root folder. All links to image files in the images folder will be directed to the original of the alias on the other drive.

Linking To Other Folders and Volumes

You can use aliases to folders and files that reside outside the WebSTAR folder, including those that reside on different volumes or mounted volumes on the network. As long as the alias resides within the WebSTAR folder, links to the file or folder will work correctly. However, you should make sure your files have relative links to other files and folders within the WebSTAR folder hierarchy--for security, WebSTAR will not serve files which are stored outside the hierarchy.

Be careful with aliases to other volumes on your network: if the volume is not available, the warning alert box on the server will override everything, including your WebSTAR server, until someone clicks the OK button.

Redirect Files

WebSTAR also supports special Redirect Files ( a special form of RAW files). These are text files which contain an HTTP redirect command, recognized by the browsers, followed by the URL for the browser to load. The WebSTAR web server checks for this information as soon as it locates the file. WebSTAR just returns the file, without processing, to the browser, and the browser then automatically requests the new URL. This happens very quickly, and is invisible to the person browsing, so all they see is the new URL in the Location field of the browser.

Redirect files are good for changing the visible URL as well as bringing up the desired file or folder.
Unlike aliases, they can't redirect to anything outside the site file hierarchy, such as files on other disks.

For example, suppose you move an entire branch of your file tree to another web server. You can redirect incoming requests to the default file for that folder simply by creating a Redirect file that contains a URL redirect header and new location. Replace the default file in that folder with the Redirect file, and browser requests will retrieve the redirect file, which sends them to the new host.

If you redirect to a folder, make sure to add the trailing slash that indicates a folder. Although the folder will be served, links to this redirect file are treated as links to a file, rather than a folder, and should not have the trailing slash.

Creating Redirect Files

To make Redirect files, use the Make Redirect File application in the Tools & Examples folder.

1 Make sure you have the URL for the target file (the file you want to redirect to ),
2 Decide on the URL and file location for the new redirect source file (the URL to redirect from ).
3 Open the Make Redirect File application, and enter the target URL in the edit field, then click OK.
4 You'll see a normal Save File dialog: give the Redirect file the new name and save it in the correct source folder.
5 Test your Redirect by opening a browser and entering the source URL (the location of the Redirect file). You should see the target file in the browser.
The WebSTAR web server log will show an entry for the Redirect file and then an entry for the target file if the target is on your server.

Internal Structure of Redirect Files

The easiest way to make Redirect files is to use the utility application, but you can also make them yourself. Redirect files are just text, but they have a Type code of "RAW!" and a creator code of "WWWω". These codes are required by WebSTAR to automate the redirection, but it makes it quite tricky to edit the files directly. You should either use a text editor that can open unknown file formats, such as BBEdit, or change the File Type code to TEXT. Be sure to change the codes back before you try to use the Redirect files, or it will not work properly.

There must be a "linefeed" character (encoded as ASCII 10 or Hex 0A ) before both the second and third lines for compatibility with old browsers. In SimpleText, these will appear as boxes if you open an existing Redirect file: do not delete them. If your text editor allows you to save in DOS format, the linefeed characters will be added automatically.

The file should include the HTTP redirect statement like this:

 

HTTP/1.1 302 Found
 
Location: http://www.domain.com/widgets/blue.html
 
Server: WebSTAR 4

With your target file or folder URL replacing the example. This structure and data tells the browser:

The browser will resubmit the request for the target URL right away.


Manual Contents | Chapter Contents | Previous Page | Next Page