|In the first part of this tutorial we discussed using server side includes to streamline your HTML code. You also learned that the decision to use the file argument or the virtual argument depends on the location of the files on the server. Now we will take a closer look at the file and virtual arguments.|
Let's study some examples. For the purpose of these examples, we have two files called index.shtml and about.shtml. These two files contain the SSI code that will "call in" a third file.
As you can see from Figure 1 above, all three of the files (index.shtml, about.shtml and menu.html) are in the same folder on your server. Therefore in this example you will use the file argument in the SSI code. Also the value (on the other side of the equal sign) is simply the name of the file to be included (menu.html). By using the file argument and the name of the file you are telling the server that it can find the file it needs (menu.html) in the same folder as the index.shtml and about.shtml files.
In this example we still have the SSI code in both the index.shtml and about.shtml webpages. Take a look at Figure 1 again. This time the file we want to include (legal.html) is in a folder below the main folder. This subfolder is called law. Because the legal.html file is in a subfolder you need to add the name of the subfolder in front of the name of the file to be included. Because the law folder is a subfolder of the main folder you will still use the file argument. This tells the server that it can find the file it needs (legal.html) in the law subfolder.
Take a look at Figure 2. In this example we still have the SSI code in both the index.shtml and the about.shtml webpages. But this time we will use the virtual argument. Why? Well this time the file to be included (refer.html) is not in the same folder or a subfolder to the main folder. It is in an independent folder on the server. That is to say this folder is "outside" of the main folder. How do you tell the server to look outside of the main folder? You need to add the / in front of the name of the folder. The / stands for the server root or domain name of your webpage (www.yoursite.com). By using this / and the virtual argument, you are telling the server that it can find the file it needs (refer.html) at the location www.yoursite.com/commons/refer.html.