简体   繁体   中英

URL Rewrite: Rewrite URL with unexisting Path

I currently have an URL:

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

Which i would gladly rewrite to

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

I currently used the following 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>>

I've noticed that no Rewrite seems to be occuring (using Fiddler etc...). Any idea whether it is possible to use URL Rewrite If the path ( SomeDb/SomeFileID in this case) does not exist on the server?

Thank you for your time and have a pleasant weekend

Found the solution with some luck:

        <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>

I hope it can be of any help for someone. The main reason why the Rewrite didn't work was because I had set StopProcessing to true.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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