Redirecting from .aspx extension to Non .aspx

Currently in our website all the pages work with with and without .aspx extension and I was asked to redirect all the urls with .aspx extension to Non .aspx url (Friendly URL)

For example :

https://mysite/resources.aspx –> https://mysite/resources

This is a pretty simple request and can be implemented by writing IIS redirect rule. I just wanted to document this as this is a frequent request in multiple projects.

Please copy the below redirect rule inside the <rewrite> node in web.config file.

<rule name="Redirecting .aspx extension" stopProcessing="true">
      <match url="^(.*).aspx$" />
      <conditions logicalGrouping="MatchAny">
	   <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      <action type="Redirect" url="{R:1}" />

I did not want this rule to apply to files with .aspx extensions like showconfig.aspx, jobs.aspx. So I added a condition to not apply the rule to the files which end with .aspx extension.

<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

So this rule will work for all urls except to the urls with physical filenames with.aspx extension.

Thank you.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

Up ↑

%d bloggers like this: