I’m struggling with a URL Rewriting rule for SiteFinity. I am trying to make sure that you can only access the homepage via / and not /default.aspx.
I tried the following rule:
<rule mode="PermanentRedirect">
<url>/default.aspx</url>
<rewrite>/</rewrite>
</rule>
Which actually works perfectly on the homepage – however it also catches /sitefinity/default.aspx and redirects off the homepage – not very helpful for content editors!
I essentially need a rule that will match when there is nothing prior to the string /default.aspx.
Can anyone help?
This should work:
^in most regular expression flavors means “start of the string”, so it wouldn’t match if the pattern is found in the middle. In addition, since<url>should be a regular expression, remember to escape the dot – a dot means “anything (except newlines)“, so your pattern matches also/defaultXaspx.