简体   繁体   English

如何在 IIS7 中为此 url 格式重定向

[英]How to redirect in IIS7 for this url format

I wonder how to do specific redirection based on the scenario below?我想知道如何根据下面的场景进行特定的重定向?

When people open this url at browser http://www.test.com/gotogoogle it will redirect them to http://www.google.com . When people open this url at browser http://www.test.com/gotogoogle it will redirect them to http://www.google.com .

You could use a RewriteMap in the IIS7 URL Rewrite module to achieve this..您可以在 IIS7 URL Rewrite 模块中使用 RewriteMap 来实现此目的..

http://learn.iis.net/page.aspx/469/using-rewrite-maps-in-url-rewrite-module/ http://learn.iis.net/page.aspx/469/using-rewrite-maps-in-url-rewrite-module/

You can achieve this with URL Rewrite module.您可以使用 URL 重写模块来实现这一点。 The rule will be (content of web.config from website root folder):规则将是(来自网站根文件夹的web.config的内容):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Go To Google" stopProcessing="true">
                    <match url="^gotogoogle$" />
                    <action type="Redirect" url="http://www.google.com/" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

If you already have web,config, then add appropriate fragment only.如果您已经有 web,config,则仅添加适当的片段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM