2

I am using urlrewriter.net and I am trying to make a redirection. So here is the condition,

If the requested url doesn't end with a / (slash) and then add / at the end of the url and redirect to added url.

So if the url is "http://www.something.com/cases" then add / and redirect it to "http://www.something.com/cases/"

I've used code but it didn't work out for me :

<if url="^~/(.+)(/){0}$">
    <redirect url="~/(.+)" to="~/$1/$"/>
</if>
Tarik
  • 79,711
  • 83
  • 236
  • 349

2 Answers2

2

I am going to answer my own question here :

I've accomplished this by using this way :

<unless url="^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.aspx|\.ashx|\.ascx|\.shtml|\.html|\.htm)(\?.+)?)$">
    <if url=".+(?&lt;!/)$">
        <redirect url="(.+)" to="$1/"/>
    </if>
</unless>

If url doesn't end with "/" then it will be redirected to the one which has "/" at the end.

I hope it helps everyone out there.

Tarik
  • 79,711
  • 83
  • 236
  • 349
0

Can you use the URL Rewrite 2.0 module? You can easily add it there, because the rewrite template for that rule is a built-into the GUI.

citronas
  • 19,035
  • 27
  • 96
  • 164
  • Well, I am thinking to move forward to URL Rewrite 2.0 since Microsoft already supports in right inside of IIS. – Tarik Sep 08 '10 at 13:04