IIS7 URL重写-添加"www"字首 [英] IIS7 URL Rewrite - Add "www" prefix

查看:175
本文介绍了IIS7 URL重写-添加"www"字首的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过IIS7中的URL重写强制将example.com重定向到www.example.com?什么样的规则应该进入web.config?谢谢.

How to force example.com to be redirected to www.example.com with URL rewriting in IIS7? What kind of rule should go into the web.config? Thanks.

推荐答案

这是Microsoft的 URL重写模块的示例2.0 将* .fabrikam.com重定向到www.fabrikam.com

This is Microsoft's sample for URL Rewrite Module 2.0 that redirects *.fabrikam.com to www.fabrikam.com

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Add www" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="www.fabrikam.com" negate="true" />
                    </conditions>
                    <action type="Redirect" url="http://www.fabrikam.com/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

这篇关于IIS7 URL重写-添加"www"字首的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆