Nick
Nick

Reputation: 2907

How to set up Umbraco to default in a subpage?

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

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?

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

Upvotes: 7

Views: 8660

Answers (3)

Goran Mottram
Goran Mottram

Reputation: 6304

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 : https://our.umbraco.com/Documentation/Reference/Routing/Routing-Properties/

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.example.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.example.com/ to http://www.example.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.example.com/index.aspx");    
    }
</script>

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

Upvotes: 5

Seydi
Seydi

Reputation: 1

This will do the trick: add a rewrite rule to the Web.Config -

    <rewrite>
        <rules>
            <rule name="Redirect to front" patternSyntax="ECMAScript" stopProcessing="true">
                <match url="^$" />
                <action type="Redirect" url="/yourViewName" />
            </rule>
        </rules>
    </rewrite>

Just include that inbetween the system.webServer tags within the configuration tags, and replace yourViewName by the appropriate view's name (like Contact or Work) and you're done!

All tested & works like a dream.

Cheers #

Upvotes: 0

MahmoudFawzy
MahmoudFawzy

Reputation: 15

you can redirect to any page using Url Rewriting Config/UrlRewriting.config

adding this Role

<add name="role1"
  virtualUrl="^~/$"
  destinationUrl="~/home"
  redirect="Application"
  redirectMode="Permanent"
  ignoreCase="true" />

Upvotes: 0

Related Questions