View Complete Thread
  • Re: How hide some values from UrlRouting querystring?

    Nov 28, 2016 01:47 AM|Yuk Ding|LINK

    Hi aizapro,

    If you means that you want to hide part of the URL for the specific URL http://localhost:6031/Post/2/sarah/nelson, then you could use my following script:

                    <rule name="URL redirect" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{REQUEST_URI}" pattern="Post/2/sarah/nelson" />
                        </conditions>
                        <action type="Redirect" url="Post/nelson" appendQueryString="false" redirectType="Temporary" />
                    </rule>
                    <rule name="rewrite back" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{REQUEST_URI}" pattern="Post/nelson" />
                        </conditions>
                        <action type="Rewrite" url="Post/2/sarah/nelson" appendQueryString="false" />
                    </rule>

    If you means you want to hide all the extension name with rewrite rule, I think it is unavailable. Because if you need to hide the URL, you need a redirect rule to the target URL and a rewrite rule to rewrite back. However, when the URL has been redirected, then the redirected URL doesn't know which URL should it rewrite back. So the rewrite rule could hide the name for only one URL. If you need to manage multiple URL, please create multiple rule for different names.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.