Configuration of SSI in IIS 7

杀马特。学长 韩版系。学妹 提交于 2019-12-06 14:36:58

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.

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!