win7 IIS7配置支持SSI服务器端包含

win7

IIS7默认没有打开SSI功能

若访问shtml会报如下错误

HTTP 错误 404.3 - Not Found
由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射。

打开SSI功能即可

控制面板--程序--打开或关闭windows功能

 

测试样例

index.shtml

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>首页index</title>
</head>
<body>
首页index
<!--#include virtual="head.shtml"-->
<!--#include file="head.shtml"-->
</body>
</html>

head.shtml

<div>
	头部div
</div>

<!--#include file="head.shtml"--> 可以写相对路径,参考:

http://happyqing.iteye.com/blog/2211945

把这两个文件放到C:\inetpub\wwwroot下

要确定你的文件的本身的编码是UTF-8就不会乱码,

效果:

windows 2008的参考

http://blog.sina.com.cn/s/blog_7042f88a010119lp.html

猜你喜欢

转载自happyqing.iteye.com/blog/2213332