1and1 Help Centre Categories

print article

Redirect to Another URL Using ASP.NET

Follow the instructions below to redirect your domain to another URL, forwarding any visitors that access your domain to the specified URL.

Use the script below as a reference for how to redirect the domain. The script has more than one redirect "rule" for each domain and a default action if no previous rule applied.

<script runat="server" Language="c#">
public void Page_Init(Object Src, EventArgs E){
    switch((Request.ServerVariables["HTTP_HOST"]).Replace("www.","")){
        case "s123456789.onlinehome.us":
            Response.Redirect("http://yourdomain.com");
            break;
        case "anotherdomain.com":
            Response.Redirect("http://anotherdomain.com/www/index.htm");
            break;
        default:
            Response.Redirect("http://www.yourdomain.com/errors/constructionPage.html");
            break;
    }
}

Replace the text in red with your respective domains/URLs. Do not include the "www" prefix for any domain after "case." Save the script as default.aspx and upload the file to the root of your webspace.

For additional information, you may want to reference: