Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gavin Harriss 15 posts 33 karma points
    Sep 13, 2010 @ 06:57
    Gavin Harriss
    0

    Redirect Page (External Url)

    I'm currently porting my Sitefinity based www.paydirt.co.nz site over to Umbraco and am having a little difficulty re-creating a simple piece of functionality...

    If you look at the main menu there's a "Forums" link which redirects to forums.paydirt.co.nz when clicked. I'm wondering what is the best method / practice for achieving this in Umbraco?

    I assume I need to create some sort of "Redirect" Document Type for myself so such items are easy to pick up via the Xslt macro for the main menu? I'm just not sure how to redirect from this Document Type.

    Any help would be greatly appreciated :)

    Cheers, Gavin

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Sep 13, 2010 @ 07:18
    Sebastiaan Janssen
    0

    Two options:

    1. You do this in the DNS of your website (point the subdomain forums to the appropriate IP address that hosts the forum).

    2. You can right click a node in Umbraco and add a domain name (forums.paydirt.no.nz).. But I am assuming that your forum will not be hosted from within Umbraco, right?

  • Gavin Harriss 15 posts 33 karma points
    Sep 13, 2010 @ 10:02
    Gavin Harriss
    0

    Hi Sebastian,

    Thanks for the reply, much appreciated. However, perhaps I haven't explained my problem very clearly...

    Is it possible to add a Document Type to an Umbraco site that has a property that can be set to an external url. This page would appear in navigation amongst normal content pages, but when clicked would simply redirect to another site. In this case it's forums.paydirt.co.nz, but it could equally be anything e.g. www.google.com, our.umbraco.org, etc.

    Basically I'm trying to replicate what I've already achieved through Sitefinity with a redirect page type.

    Cheers, Gavin

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Sep 13, 2010 @ 14:31
    Sebastiaan Janssen
    0

    Ehm, yes that is possible by putting a usercontrol that does the redirect on the destination page. But what would be the point of having it in the CMS? It's just a link right, you can put it in your masterpage or XSLT..

  • Gavin Harriss 15 posts 33 karma points
    Sep 13, 2010 @ 22:13
    Gavin Harriss
    0

    Cheers for the suggestion. Was just hoping there might have been a more elegant solution that could be implemented as a Document Type.

    Just wanted to make it easy for non-techy types to drop this sort of functionality in to the site ;)

    This is just my practice site before I move a much larger site across.

  • Gavin Harriss 15 posts 33 karma points
    Sep 14, 2010 @ 00:51
    Gavin Harriss
    0

    I'm now thinking a more elegant solution might be to have a Document Type that has a property for url and another for target. This would then be picked up by my xslt for the menu and render the link directly rather than requiring a post back to do a redirect.

  • Gavin Harriss 15 posts 33 karma points
    Sep 18, 2010 @ 06:32
    Gavin Harriss
    0

    Here we go, someone's already provided a solution...

    http://www.proworks.com/blog/2010/09/17/proworks-redirect-page-umbraco-package/

  • Mark Downie 8 posts 28 karma points
    May 30, 2012 @ 14:13
    Mark Downie
    0

    I know this is an old post, but if anyone else has the same issue I have put an alternative way of doing this here:

    This method uses a c# web form

    http://markdevelopmentblog.blogspot.co.uk/2012/05/umbraco-c-redirect-umbraco-page-to.html


    Two create a redirect from a Umbraco page to an exteral site you can:

    Step 1) Add the page to Umbraco that you want to rediect. (You may want to Hide this page from navigation)

    Step 2) Create a new Web Form in C# Visual Studio
    (this web form will be placed in the route of the site)

    Step 3) Update the Web Config to include the new file mentioned in step 2
    (or you will get a Server error in appliaction)

    Step 4) Add a Url redirect to the UrlRewriting.config, from the Umbraco page (created in step 1), to the web form (created in step 2).

    Step 2: Here is the C# Code (my-redirect-example.aspx) form for step 2:
    (it is basically a blank form)

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="my-redirect-example.aspx.cs" Inherits="my_redirect_example" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    </head>
    <body onload="open_on_entrance()">
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
    </body>
    </html>


    Here is the C# Code (my-redirect-example.aspx.cs) form for step 2:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class my_redirect_example : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    Response.Redirect("http://www.markdownie.me.uk");
    }
    }


    Step 3: Here is the line you need to add to the Web Config file  for step 3:

    Add this in your <appSettings> section.

    <add key="umbracoReservedUrls" value="~/my-redirect-example.aspx" />


    Step 4: Here is the Code you need to add to the UrlRewriting.config file:

    <add
    name="myExternalRedirect"
    virtualUrl="^~/my-page.aspx"
    destinationUrl="~/my-redirect-example.aspx"
    ignoreCase="true"
    redirect="Application"
    redirectMode="Permanent"/>


    Note: Highlighted Yellow, ^~/my-page.asp . This is the name of the Umbraco Page you create in Step 1.

     

  • qrayg 24 posts 92 karma points
    Aug 07, 2015 @ 18:03
    qrayg
    1

    Is there a reason why you wouldn't just create a new DocType with a field called pageRedirect and a Template that looks like this?

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
      if(@CurrentPage.pageRedirect != ""){
        Response.Redirect(@CurrentPage.pageRedirect);
      }
    }
    

    What are the pros/cons of this?

  • Nelson 94 posts 246 karma points
    Jan 29, 2016 @ 10:38
    Nelson
    0

    Hi qrayg, does this solution works? Where to put the link for the external website?

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft