关于iis web.config 域名跳转问题

dengkeyu 2017-09-07 01:10:25
win2008 r2 系统 iis 7.0

要求:

http://xxx.com
http://www.xxx.com
https://xxx.com

全部跳转到 https://www.xxx.com

web.config 怎么修改?
...全文
1856 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
dengkeyu 2017-09-09
  • 打赏
  • 举报
回复
终于解决了!非常感谢您啊,特别是你的热心和回复及时!
X-i-n 2017-09-08
  • 打赏
  • 举报
回复
一个站点也一样处理啊,http的判断条件改为无https,再把规则合并到一个站点上,然后匹配模式从“全部匹配”切到“任意匹配”就行。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="self" stopProcessing="true">
                    <match url="(.*)" negate="false" />
                    <action type="Redirect" url="https://www.xxx.com/{R:0}" logRewrittenUrl="true" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{HTTP_HOST}" pattern="^xxx.com" />
                        <add input="{HTTPS}" pattern="off" />
                    </conditions>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
dengkeyu 2017-09-08
  • 打赏
  • 举报
回复
你这个太麻烦了,我以前写过的,就绑定一个站点,就能实现的,可惜我忘记当时 web.config 是怎么写的了...
dengkeyu 2017-09-08
  • 打赏
  • 举报
回复
按照你的要求,测试,所有跳转都失效了...
X-i-n 2017-09-08
  • 打赏
  • 举报
回复
之前是我理解得有问题,URL匹配不包含域名部分,而是https://xxx.com/abc/abc.html?t=1 中的标红部分。 所以只要用(.*)来匹配整个URL(匹配变量是 {R:0}),加到新的HOST后面。最终效果是:将URL中的HOST部分 http(s)://xxx.com 替换成新域名,别的部分不变。 完整的站点设置方法是添加两个站点,一个绑http,一个绑https,各自用一条重定向规则,两个站点的匹配规则不一样,重定向行为一样。 ·http站点绑定域名http://xxx.com和http://www.xxx.com,规则是:匹配所有URL,重定向到https://www.xxx.com。 ·https站点的规则是:匹配HOST是https://xxx.com的访问(匹配条件,HTTP_HOST以xxx.com开头,xxx.com匹配命中,www.xxx.com匹配不命中),重定向到https://www.xxx.com。 HTTP的

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="redirect80" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Redirect" url="https://www.xxx.com:9443/{R:0}" redirectType="Permanent" />
                    <conditions>
                        <add input="{URL}" pattern="(.*)" />
                    </conditions>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

HTTPS的
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="redirect443" stopProcessing="true">
                    <match url="(.*)" negate="false" />
                    <action type="Redirect" url="https://www.xxx.com:9443/{R:0}" logRewrittenUrl="true" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^xxx.com" />
                    </conditions>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
X-i-n 2017-09-07
  • 打赏
  • 举报
回复
直接用这个试试,匹配所有URL,将url里xxx.com后面的部分(比如 https://xxx.com/a.html中的 /a.html)保留,前面的部分无脑替换成 https://www.xxx.com
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="rewrite">
                    <match url="^(.*)" />
                    <conditions>
                        <add input="{URL}" pattern="^(.*xxx.com)(.*)" />
                    </conditions>
                    <action type="Rewrite" url="https://www.xxx.com/{C:2}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
dengkeyu 2017-09-07
  • 打赏
  • 举报
回复
<rule name="WWW Redirect" stopProcessing="true"> <match url="^(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" /> </conditions> <action type="Redirect" url="https://www.xxx.com/{R:0}" redirectType="Permanent" /> </rule> 这个实现了 http://xxx.com http://www.xxx.com 跳转到 https://www.xxx.com 但是没有实现 https://xxx.com 跳转到 https://www.xxx.com 怎么解决?
dengkeyu 2017-09-07
  • 打赏
  • 举报
回复
不行,麻烦你按照我的要求写个web.config 给我
X-i-n 2017-09-07
  • 打赏
  • 举报
回复
http://blog.csdn.net/u013378306/article/details/51064508 IIS管理器配置和web.config配置两种方法都有
安装环境:php5.2-php5.6、mysql5或更高版本 飞飞影视导航系统 安装说明 1. 将文件夹下所有的文件上传至您的网站空间 2. 如果您的主机为 window 操作系统,请将以下文件夹的IIS用户加上写入权限 3. 如果您的主机为 linux 操作系统,请设置如下文件夹权限为 777 ./Runtime/* 系统缓存目录 ./Uploads/* 系统附件保存目录 4. 通过浏览器访问 http://您的域名/install.php,根据提示填写 mysql 配置信息 5. 完成安装后会自动跳转到后台,默认用户名是admin 密码是admin888 6. 后台路径为http://您的域名/admin.php(强列建议将admin.php改一个不容易猜到的名字) 7. 如果您要使用飞飞影视导航系统建站,请保留官方站的友链链接与版权信息! 1、确认空间支持rewrite组件并完成配置,以下为各用WebServer对应的模块。 [ Apache ] httpd.conf配置文件中加载了mod_rewrite.so模块 AllowOverride None 将None改为 All .htaccess文件放到index.php的同级目录 [ IIS6.x ] 支持ISAPI_Rewrite的话,可以配置httpd.ini文件 httpd.ini文件放到index.php的同级目录 [ IIS7.x ] web.Config文件放到index.php的同级目录或在中间添加rewrite节点 [ Nginx ] 将web.conf里面的代码复制到你的网站配置的 location /{.....}中间 重启nginx即可 2、网站后台》系统》URL优化:开启重写功能。 3、根据需要自己个性化URL规则(可选) 备注: 默认规则及详细文档请参考以下文档如下,http://daicuo.co/forum-175-1-1.html

6,868

社区成员

发帖
与我相关
我的任务
社区描述
Windows 2016/2012/2008/2003/2000/NT
社区管理员
  • Windows Server社区
  • qishine
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧