使用iis rewriter将路径转换为查询字符串

时间:2015-01-21 22:39:23

标签: iis web-config

使用IIS 7.5的IIS重写器我想拥有以下URL: http://www.contoso.com/FOLDER1/FOLDERX/PLACE2/SomeImportantText/1bab8a84-8d06-478f-badd-6af4248661a7/MoreImportantText 转换成: http://www.contoso.com/something.aspx?X=SomeImportantText&Y=1bab8a84-8d06-478f-badd-6af4248661a7&Z=MoreImportantText 应该排除域名,以便这是一个相对网址。 我如何在web.config文件

中执行此操作

我正在尝试:

    <rules>
         <rule name="Rewrite Language">
                <match url="^/FOLDER1/FOLDERX/PLACE2/([^/]*)/([^/]*)/([^/]*)$" />
                <action type="Rewrite" url="/something.aspx?X={R:1}&amp;Y={R:2}&amp;Z={R:3}" /> 
         </rule>
    </rules>

1 个答案:

答案 0 :(得分:0)

这有效:

         <rule name="Working Rewrite Language">
            <match url="^FOLDER1/FOLDERX/PLACE2/([^/]*)/([^/]*)/([^/]*)$" />
            <action type="Rewrite" url="something.aspx?X={R:1}&amp;Y={R:2}&amp;Z={R:3}" /> 
         </rule>