URL 重写:用不存在的路径重写 URL
URL Rewrite: Rewrite URL with unexisting Path
我目前有一个URL:
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>>
我注意到似乎没有发生重写(使用 Fiddler 等...)。知道是否可以使用 URL Rewrite
如果服务器上不存在路径(SomeDb/SomeFileID
在这种情况下)?
感谢您的宝贵时间,祝您周末愉快
幸运地找到了解决方案:
<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。
我目前有一个URL:
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>>
我注意到似乎没有发生重写(使用 Fiddler 等...)。知道是否可以使用 URL Rewrite
如果服务器上不存在路径(SomeDb/SomeFileID
在这种情况下)?
感谢您的宝贵时间,祝您周末愉快
幸运地找到了解决方案:
<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。