Configuration of SSI in IIS 7

2.7k views Asked by At

I've installed ServerSideIncludes module on my computer and it works great with one exception.

<!--#include virtual="meta.inc" -->

The line above is causing the problem. I know I must change virtual with file but I have a huge website and it means I must change at least 1000 line of code like this and I am looking for a way to run virtual properly in IIS 7.

I've been looking for this solution but all I've been able to find the solution I've mentioned above.

Do you know how to solve this problem without changing the virtual to file

Thanks.

3

There are 3 answers

3
Jakkwylde On

Do you have parent paths enabled over your site? Navigate to the "ASP" section of your site in IIS and select "Enable Parent Paths" in the "Behavior" section and see if that helps.

The Parent Paths option permits you to use ".." in calls to functions such as MapPath by allowing paths that are relative to the current directory using the ..\notation. Setting this property to True may constitute a security risk because an include path can access critical or confidential files outside the root directory of the application.

0
DavidRR On

This is not really an answer but instead is more a confirmation of your problem. But see one possible way that virtual might work for you at the end of my answer.

From the MSDN blog post IIS: Notes on Server-Side Includes (SSI) Syntax (KB 203064 Revisited) (dated 2010-12-28; applies to IIS versions 4.0 through 7.5):


More Information on File and Virtual Syntax

SSI directives that use file paths can reference files by using a file or virtual path.

  • The file element is used with files that are relative to the folder of the current document. The following example includes a file in the current folder:
<!--#include file="myfile.txt"-->
  • The virtual element represents paths that are relative to the base folder of the Web server. The following example includes a file in the /scripts virtual folder:
<!--#include virtual="/scripts/myfile.txt"-->

Conclusion: The file attribute is used to designate a file location that is relative to the current document. So, if that is what is needed in your situation, you'll indeed need to change the virtual attribute to the file attribute.

There is one possible exception, though. The article Server Side Includes on Wikipedia shows the following example:

<!--#include virtual="menu.cgi" -->

This suggests to me that a virtual file path does not necessarily need to begin with a /. In the absence of a leading /, the location of a virtual file is relative to the base folder of the web server.

So, it appears to me that the file and virtual attributes might behave identically if the files being referenced happen to be located in the base folder (or subfolders of the base folder) of the web server.

0
Randolf Richardson On

SSI is not ASP -- they're different technologies.

I have found that each time Microsoft releases a new version of any of their products that sometimes certain features that worked in previous versions work differently or not at all in the newer versions, and it looks like this problem may be one of those.

So, you might want to consider switching to Apache HTTPd (if you can) and then you won't need to make all those changes to your files -- I've found that Apache has been consistent in their support for SSI (and other technologies/modules, configuration directives, etc.) in all versions of HTTPd that support it. This consistency is one of the reasons I really like it.