解决IIS7多域名绑定同一物理目录,设置不同的默认文档的问题

来源:互联网 发布:大学生网络安全意识 编辑:程序博客网 时间:2024/06/04 19:14
IIS7多域名绑定同一物理目录,设置不同的默认文档是没办法设置的,因为在一个物理目录下只有一个web.config,并且IIS7把默认文档设置写在这里,导致所有域名的默认文档设置共享。
解决方法:
1、进入%windir%\system32\inetsrv\config目录(%windir%即windows的安装目录,比如c:\windows) 
2、找到applicationHost.config文件,用文本编辑器打开,如果打不开就复制出来修改后再替换原来的文件(建议备份原文件,以防不测,这是工作习惯。) 

3、在最后configuration节中加入如下语句 

   <location path="A站点名称,例www.xxx.net">          <system.webServer>             <defaultDocument enabled="true">                <files>                           <clear/>                      <add value="index.html"/>                </files>             </defaultDocument>         </system.webServer>     </location>   <location path="B站点名称,例wap.xxx.net">          <system.webServer>             <defaultDocument enabled="true">                <files>                           <clear/>                      <add value="wapindex.html"/>                </files>             </defaultDocument>         </system.webServer>     </location> 

只加需要特别指定默认文档的站点,有几个加几个,无需重启IIS。 

如以上方式不成功的话,在两个站点的默认文档里,先恢复默认文档为“恢复为继承的项”,然后再去设置applicationHost.config就可以了

阅读全文
0 0
原创粉丝点击