Reputation: 137
I have already been through the related questions and couldn't find anything that'd help. So here is my question.
The shared servers where my site is uploaded are being updated and they recently installed the latest IIS (7.5 I think). They installed the Rewrite Module as well.
Before this update I used wildcard (through aspnet_isapi filter) mapping to rewrite paths like mysite.com/contact to mysite.com/pages/contact.aspx
Now, I am required to use the in the configuration file but the regex is giving me a headache.
I want to redirect all the .aspx files to pages/[filename].aspx
but ignore the ones that are static files like .css, .jpg, .png etc
I end up using:
<rewrite>
<rules>
<rule name="wildcard">
<match url="(.*)" />
<action type="Rewrite" url="pages/{R:1}.aspx" />
</rule>
</rules>
</rewrite>
Using the above the following works:
mysite.com/contact
etc
but these not
mysite.com/contact/
mysite.com/css/style.css
mysite.com/
etc
Can somebody help? Let me know if you need more information.
Thanks
Upvotes: 1
Views: 3134
Reputation: 155418
Have you tried the "Is Not File" and "Is Not Directory" conditions?
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
Upvotes: 3