How to set up Umbraco to default in a subpage?

Nick picture Nick · Feb 3, 2012 · Viewed 8.4k times · Source

I have this question about umbraco structuring and I can't find the answer anywhere.

Typically in Umbraco it will default the root site to the first node of the tree. so if we have

  • Home
    • page 1
    • page 2

the default page will be home (so www.mysite.com will point to home).

How do I change this however so that www.mysite.com will point to page1 or page2? What if I have this structure?

  • wrapper
    • index
    • page 1
    • page 2

and I want www.mysite.com to go straight to www.mysite.com/index.aspx

I couldn't find a rule that does that. Tried inserting a rewrite/redirect rule and it didn't change anything.

Please help

Nick

Answer

Goran Mottram picture Goran Mottram · Feb 3, 2012

Redirecting in Umbraco is usually a very simple affair, except when you're trying to redirect from the root node of your site.

Method 1:

It explains it best here : http://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracoredirect

So it's possible by adding a umbracoInternalRedirectId property to your root node, with the data type of Content Picker. Note that it does not redirect the user but instead load the contents of that page inside the current url. So the URL will remain as http://www.mysite.com whilst serving the contents of the page that you want to redirect to.

Method 2:

If you really want it to change from http://www.mysite.com/ to http://www.mysite.com/index.aspx. I usually add something like the following code to the template of the root node.

<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
</asp:Content>
<script type="c#" runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Redirect("http://www.mysite.com/index.aspx");    
    }
</script>

So that ASP.Net is responsible for the redirect. But it obviously won't handle node rename/moving too well.