How to set up Umbraco to default in a subpage?
Asked Answered
V

3

7

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

Venepuncture answered 3/2, 2012 at 15:46 Comment(0)
A
5

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.

Aldus answered 3/2, 2012 at 16:40 Comment(2)
No worries. Just make sure you can still save XSLTs without error (if you're even using them). That's the main reason why using Umbraco's redirect system can be so tricky on the root node, as explained in that link above.Aldus
I am only using razor instead of XSLT and the site seems to render perfectlyVenepuncture
M
0

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" />
Myers answered 5/5, 2015 at 13:42 Comment(0)
V
0

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 #

Vaporetto answered 22/10, 2021 at 13:28 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Remy

© 2022 - 2024 — McMap. All rights reserved.