I've unfortunately got a lot of pages SEO-indexed with "/home" as prefix. Now I need to change to prefixless urls in Piranha, which is easy. But is there a place where I can force redirects from old urls to new urls? E.g. redirect "www.example.com/home/page" to "www.example.com/page". The problem is that the old page doesn't exist anymore so I can't put a script on that page to do the redirect. Best regards Lars, Denmark
I think the best way is to use url rewrite module (need to install it from web platform). In web.config You can append rewrite rules to system.webServer => rewrite => rules.
I will not test it, but it should be something like this:
<system.webserver>
<rewrite>
<rules>
<rule name="RedirectToPrefixless" stopProcessing="true">
<match url="^home/(.*)" />
<action type="Redirect" url="{R:1}" />
</rule>
</rules>
</rewrite>
</system.webserver>
Tag "match" finds for urls begining with "home/" - part of regex "(.*)" create group which will be used in redirect url
Tag "action" states, that for matching URL it should be redirected to "(.*)" part from "match" part.
So for example:
All redirects are "Permanent" (http status 301) - it can be also changed ;)