Contact Us  |  Knowledge Base  |  Control Panel 
Article Details
Force WWW to be in the URL

ISSUE:

Some times people like for their DotNetNuke site to always have "www." before their domain name.  This is not possible to do in DotNetNuke directly.

RESOLUTION

You can only make this redirect work on the person's first load.

Save this file as Index.aspx into your site's root folder.
-------------------------------------

<script runat="server" language="C#">
private void Page_Load(object sender, System.EventArgs e)
{
    string URL = Request.Url.Host;
    if (! URL.ToLower().StartsWith("www."))
    {
        URL = "www." + URL;
    }

    URL = Request.Url.Scheme + "://" + URL;
    URL = URL + "/default.aspx";
   
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location", URL);
}
</script>

-------------------------------------