SiteFinity URL Rewriting Regular Expression
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
.
Ca开发者_如何转开发n anyone help?
This should work:
<url>^/default\.aspx</url>
^
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
.
I'm a little unsure of how things are looking from your machine's perspective.
I'm thinking that you would want to do a 'search and replace' like this.
strreplace "/default.aspx" with "/"
and then don't do anything with the other cases.
精彩评论