Sandeep Sandeep - 1 year ago 77
ASP.NET (C#) Question

IIS - redirect urls which are not ending with aspx to some page

I am using intelligencia urlrewriter and I want to redirect all urls which are not ending with .aspx or .html to some page of web application but not able to figure out regex pattern required for it. I have tried pattern


but seems like it is now working with IIS rewite rule or i am missing something. I need help to solve this problem.

Answer Source

Do you have to use Intelligencia UrlRewriter? Or IIS rewrite rules would also be OK? Seems like you are trying both...

If you can use IIS rewrite rules, then you can negate the whole regex pattern, for example:

<rule name="Test" stopProcessing="true">
     <match url="^.*\.(html|aspx)$" negate="true" />
     <action type="Redirect" url="/" appendQueryString="false" />


Regex to match all URLs not ending with .aspx or .html


I haven't tested it on Intelligencia UrlRewriter though.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download