Mobile app version of vmapp.org
Login or Join
Alves908

: Do a redirect in IIS, but show the original pretty url? The following case: A visitor comes in on http://www.example.com/pretty. This gets redirected to http://www.example.com/?ID=ugly. This part

@Alves908

Posted in: #Iis #UrlRewriting

The following case:

A visitor comes in on www.example.com/pretty. This gets redirected to www.example.com/?ID=ugly. This part works.

However, we'd like the visitor to keep seeing www.example.com/pretty in the address bar of his browser, instead of www.example.com/?ID=ugly.
We've tried various combinations in the URL Rewrite module, but none seem to get us the desired result.

Is this even possible?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Alves908

1 Comments

Sorted by latest first Latest Oldest Best

 

@Sherry384

This eventually did the trick.
ugly URL: domain.com/?CatID=1167 pretty URL: domain.com/people
<rewrite>
<rules>
<rule name="Redirect /people" enabled="true" stopProcessing="true">
<match url="^$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^catid=1167$" />
</conditions>
<action type="Redirect" url="/people" appendQueryString="false" />
</rule>
<rule name="Rewrite /people" enabled="true" stopProcessing="true">
<match url="^people$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="?catid=1167" />
</rule>
</rules>
<outboundRules>
<rule name="OutboundRewrite /people" preCondition="ResponseIsHtml1" stopProcessing="false">
<match filterByTags="A, Form, Img" pattern="catid=1167$" />
<action type="Rewrite" value="/people" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme