URL重写:使用未显示的路径重写URL

时间:2015-07-31 13:16:13

标签: asp.net .net iis url-rewriting

我目前有一个网址:

http://someDomain.com/SomeVirtualDirectory/SomeDb/SomeFileID

我很乐意改写

http://someDomain.com/SomeVirtualDirectory/Get.aspx?page={REQUEST_URI}" 

我目前使用以下Inbound Rule

        <rule name="CatchAll" stopProcessing="true">
          <match url=".*" />
          <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Redirect" url="http://someDomain.com/SomeVirtualDirectory/Get.aspx?page={REQUEST_URI}" logRewrittenUrl="true" />
        </rule>>

我注意到似乎没有出现Rewrite(使用Fiddler等......)。不知道是否可以使用URL Rewrite 如果服务器上不存在路径(在这种情况下为SomeDb/SomeFileID)?

感谢您的时间,度过愉快的周末

1 个答案:

答案 0 :(得分:0)

找到解决方案,运气好:

        <rule name="CatchAll" stopProcessing="false">
          <match url=".*" />
          <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="Get.aspx?page={R:0}" logRewrittenUrl="true" />
        </rule>

我希望它对某人有任何帮助。 Rewrite无效的主要原因是我将StopProcessing设置为true。