Board logo

标题: IIS7-8.5 多域名绑定同一物理目录不同默认文档的实现方法. [打印本页]

作者: 万众海浪    时间: 2020-8-8 07:13     标题: IIS7-8.5 多域名绑定同一物理目录不同默认文档的实现方法.

因为在一个物理目录下只有一个web.config,并且IIS7把默认文档设置写在这里,导致所有域名的默认文档设置共享。

1、进入%windir%\system32\inetsrv\config目录(%windir%即windows的安装目录,比如c:\windows)

2、找到applicationHost.config文件,用文本编辑器打开,如果打不开就复制出来修改后再替换原来的文件(建议备份原文件,以防不测,这是工作习惯。)

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

4、将web.config下网站自动生成的默认首页节点删除掉。
<location path="Shou">
     <system.webServer>
      <defaultDocument enabled="true">
        <files>   
           <clear/>
           <add value="shouindex.aspx"/>
        </files>
      </defaultDocument>

    </system.webServer>
  </location>
只加需要特别指定默认文档的站点,有几个加几个,无需重启IIS。
作者: 万众海浪    时间: 2020-8-8 07:22     标题: 利用JS判断当前来路域名并自动跳转到指定页面

<!DOCTYPE html>
<html>
<head>
        <title>玩命加载中……</title>
        <!-- 判断访问的域名并自动跳转 -->
        <script type="text/javascript">
        if (window.location.href.indexOf("demo123.com") > -1) {
                window.location.href='http://www.demo.com/123/';
        } else if (window.location.href.indexOf("demo456.com") > -1) {
                window.location.href='http://www.demo.com/456/';
        } else if (window.location.href.indexOf("demo789.com") > -1) {
                window.location.href='http://www.demo.com/789/';
        }
        </script>
</head>
<body>

</body>
</html>




欢迎光临 万众海浪论坛 (http://281889.com/bbs/) Powered by Discuz! 5.5.0