Copied to clipboard

Flag this post as spam?

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


  • Amigo 243 posts 568 karma points
    Aug 13, 2014 @ 21:16
    Amigo
    0

    Shortening urls

    Hi,

    I need to do something where the backend user can type specific short urls like xxx.com/shorttekt (maybe on a special pagetype that holds key/values or so...).
    When hit in browser, the url typed, will then do a permanent 301 redirect to an existing page with longer url like xxx.com/folder/folder/folder/shorttekt.

    Any ideas?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 13, 2014 @ 22:02
    Dennis Aaen
    0

    Hi Amigo,

    A possible solution could be use to the 301 URL Tracker package, http://our.umbraco.org/projects/developer-tools/301-url-tracker.

    The way I was thinking that you could do it was by creating a page in your site structure, like xxx.com/shorttekt, and then make a 301 redirect with the 301 URL Tracker package to the page with the long url. xxx.com/folder/folder/folder/shorttekt.

    Hope this helps,

    /Dennis

  • Amigo 243 posts 568 karma points
    Aug 16, 2014 @ 07:29
    Amigo
    100

    Hi,

    I actually ended up with a pagetype that holds one multi url picker.
    The website editor can here create ´n amount of items that hold: a "title" (the shorttekt i need) and a link to an internal page (the page i need to redirect to).
    And then... When my landing page is loaded i do something like this to find the shorttext and create a redirect:

     public void Page_Init(object o, EventArgs e)
    {

                DynamicNode dn = new DynamicNode(xxxx); // get smarturl page and find multiurlpicker
                var urlPicker = uComponents.DataTypes.MultiUrlPicker.Dto.MultiUrlPickerState.Deserialize(dn.GetPropertyValue("xxx"));
                string strCurrent= Request.Url.AbsolutePath;
                string strName = strCurrent.Substring(strCurrent.LastIndexOf("/") + 1);

         foreach (var item in urlPicker.Items
         {
              if (strName.ToLower() == item.Title.ToLower())
                   {
                       Response.Clear();
                       Response.StatusCode = 301;
                       Response.RedirectLocation = item.Url;
                       Response.End();

    }
    }



     

Please Sign in or register to post replies

Write your reply to:

Draft