WhilseySoon WhilseySoon - 23 days ago 6
ASP.NET (C#) Question

ASP.NET url redirect without child

<rule name="news_en">
<match url="en/news/"/>
<action type="Rewrite" url="en/blog/NewsList.aspx"/>
</rule>


It redirects too if url looks like [...]/en/news/id1234; but I don't need that. What should I do?

Answer

Try this:

    <rule name="news_en">
      <match url="^en/news/$"/>
      <action type="Rewrite" url="en/blog/NewsList.aspx"/>
    </rule>   

^ means matching will start from the begin of the domain name. So www.yourdomain.com/en/news/ will redirect while www.yourdomain.com/pages/en/news/ will not.

$ nothing is allowed behind the matched string.

Comments