asp.neturl-rewritingurlrewriting.net

Using URL Redirection based on domain name using UrlRewritingNet.UrlRewriter


I want to redirect a request in an asp.net web site based on the domain, my scenario is like this.

I have the app setup so that it will process the requests from multiple domains like from www.abc.com and www.xyz.com, now i want that when ever a request comes to the www.abc.com/default.aspx the url would be rewrites to the www.abc.com/custom/abcdefault.aspx while for all the other requests like for www.xyz.com/default.aspx it should do nothing.

I am currently using the UrlRewritingNet.UrlRewriter for the URL rewriting,

Thanks,


Solution

  • try something along this:

    <add name=”Redirect_abc.com”  virtualUrl=”^http\://www.abc.com/default.aspx”
    rewriteUrlParameter=”ExcludeFromClientQueryString”
    destinationUrl=”http://www.xyz.com/custom/abc.default.aspx″
    redirect=”Domain”
    redirectMode=”Permanent”
    ignoreCase=”true” />
    

    This just matches the pattern you specified before but can easily be changed to match another patetrn.

    Regards

    Jonathan