To handle 301 redirect we have made changes in pipeline and written following class
public class CustomRedirect301 : PreprocessRequestProcessor
{
public override void Process(PreprocessRequestArgs args)
{
var targeturl = objDB.GetTargetURL(args.Context.Request.Url.PathAndQuery.TrimEnd(new[] { '/' });)
args.Context.Response.RedirectPermanent(targeturl, true);
}
}
In GetTargetURL function we pass incoming URL part only after domain for example incoming request is www.mysite.com/healthcare we pass /healthcare and this function return actual url where user should redirect let's say www.mysite.com/part-1/part-2/healthcare
We maintain this mapping in database table with two column UrlFrom and UrlTo so in this case
UrlFrom is /healthcare
UrlTo is www.mysite.com/part-1/part-2/healthcare
But now we have one request where we have to redirect abc.mysite.com to www.mysite.com/part-1/part-2/part-3
In this case we don't have any URL part after domain to pass as input parameter in GetTargetURL function so how can we achieve this.
Environment: Sitecore 8.1 MVC / Multisite implementation
url rewrite module
. – Marek Musielak Mar 15 '17 at 21:54