Redirect a Site to Sub-directory with a Little aspx code snip

So my problem was I installed DotNetNuke on a web host provider, but they forced you to put the install into a subdirectory.  I needed a way to permanently redirect anything that came in to http://original.com to http://original.com/new.  Turns out that the following little code snip does the trick, all without losing your search engine ranking – double score!  I saved this in the root of the (ASP.net) site as Default.aspx

<script language=”c#” runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(“Location”,”http://www.new-url.com”);
}
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *