【问题标题】:IIS Url rewrite usernameIIS Url 重写用户名
【发布时间】:2013-05-13 03:37:05
【问题描述】:

如何在 IIS 中重写此网址

mysite.com/profile.aspx?user=foo

mysite.com/foo

我在 .htaccess 中尝试过的这种重写条件

RewriteRule /foo/(.*) /bar?arg=P1\%3d$1 [R,NE]

但是如何在 IIS Url Rewrite 中做到这一点?

【问题讨论】:

    标签: asp.net iis url-rewriting


    【解决方案1】:

    很简单:

    <rule name="Profile Rewrite" stopProcessing="true">
        <match url="^([^/]+)/?$" />
        <conditions>
            <add input="{REQUEST_FILENAME}" matchType="isFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="isDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="profile.aspx?user={R:1}" />
    </rule>
    

    请注意,您的 Apache 重写规则实际上根本不会达到您的预期。另请注意,您可以通过 IIS 管理器中的 URL 重写可视化配置工具轻松生成此文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-07
      • 2013-07-01
      • 2016-06-27
      • 2013-06-16
      相关资源
      最近更新 更多