IIS 7 中 SSI 的配置

发布于 2024-08-13 06:43:04 字数 395 浏览 5 评论 0原文

我已经在我的计算机上安装了 ServerSideInincludes 模块,它运行良好,但有一个例外。

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

上面的行导致了问题。我知道我必须用 file 更改 virtual 但我有一个巨大的网站,这意味着我必须更改至少 1000 行这样的代码,我正在寻找一种方法在 IIS 7 中正确运行virtual

我一直在寻找这个解决方案,但我只能找到上面提到的解决方案。

您知道如何在不将 virtual 更改为 file 的情况下解决此问题吗?

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

没企图 2024-08-20 06:43:04

您的网站上启用了父路径吗?在 IIS 中导航到站点的“ASP”部分,然后在“行为”部分中选择“启用父路径”,看看是否有帮助。

“父路径”选项允许您在调用 MapPath 等函数时使用“..”,方法是允许使用 ..\ 符号相对于当前目录的路径。将此属性设置为 True 可能会构成安全风险,因为包含路径可以访问应用程序根目录之外的关键或机密文件。

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.

漫雪独思 2024-08-20 06:43:04

这并不是真正的答案,而是对您的问题的确认。但在我的答案的最后,请参阅virtual可能对您有用的一种可能的方式。

来自 MSDN 博客文章 IIS:有关服务器端包含 (SSI) 语法的说明(KB 203064 重访) (日期为 2010 年 12 月 28 日;适用于 IIS 版本 4.0 至7.5)


有关文件和虚拟语法的更多信息

使用文件路径的 SSI 指令可以通过使用文件虚拟来引用文件小路。

  • file 元素用于与当前文档的文件夹相关的文件。以下示例包括当前文件夹中的一个文件:
<!--#include file="myfile.txt"-->
  • virtual 元素表示相对于 Web 服务器的基本文件夹的路径。以下示例在 /scripts 虚拟文件夹中包含一个文件:
<!--#include virtual="/scripts/myfile.txt"-->

结论: file 属性用于指定相对于当前文档的文件位置。因此,如果这是您的情况所需要的,您确实需要将 virtual 属性更改为 file 属性。

不过,有一个可能的例外。 Wikipedia 上的文章 服务器端包含 显示了以下示例:

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

这向我表明 < code>虚拟文件路径不一定需要以/开头。如果没有前导 /,则 虚拟 文件的位置相对于 Web 服务器的基本文件夹。

因此,在我看来,filevirtual 属性的行为可能相同如果被引用的文件碰巧位于 Web 服务器的基本文件夹(或基本文件夹的子文件夹)中。

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.

π浅易 2024-08-20 06:43:04

SSI 不是 ASP——它们是不同的技术。

我发现,每次微软发布任何产品的新版本时,有时在以前版本中工作的某些功能在新版本中工作不同或根本不起作用,看起来这个问题可能就是其中之一。

因此,您可能需要考虑切换到 Apache HTTPd(如果可以的话),然后您就不需要对文件进行所有这些更改——我发现 Apache 在对 SSI(以及其他技术/模块、配置指令等)在所有支持它的 HTTPd 版本中。这种一致性是我真正喜欢它的原因之一。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文