Copied to clipboard

Flag this post as spam?

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


  • Donald Swofford 13 posts 107 karma points
    Aug 06, 2014 @ 22:29
    Donald Swofford
    0

    How can I redirect to an external url

    I would like to pick various directory names for example  http://mydomain.com/google/  and forward them to external (maybe some internal) urls such as www.google.com

    I have tried some different code etc from forums but they dont seem to work.  I am using umbraco 7.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 07, 2014 @ 08:08
    Dennis Aaen
    100

    Hi Donald,

    Maybe you should have a look on the 301 URL Tracker package from Stefan Kip, with this package you can create your own redirects, based on a simple URL or using a Regex pattern. You can redirect to an existing node or a manually entered URL.

    http://our.umbraco.org/projects/developer-tools/301-url-tracker

    Hope this helps, and could be a solution for you.

    /Dennis

  • Troels Larsen 75 posts 280 karma points
    Aug 07, 2014 @ 09:23
    Troels Larsen
    0

    Hey Donals you could allso make and external url field on all your pages nad make and urlprovider so handle the redircts. that way you override it a very lowlevel and all your IPublishedContent.Url will work as entended 

    public class ExternalUrlProvider : IUrlProvider

        {

            public IEnumerable<string> GetOtherUrls(Umbraco.Web.UmbracoContext umbracoContext, int id, Uri current)

            {

                return Enumerable.Empty<string>();

            }

     

            public string GetUrl(Umbraco.Web.UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode)

            {

                var currentNode = umbracoContext.ContentCache.GetById(id);

                if (currentNode != null)

                {

                    var externalLink = currentNode.GetPropertyValue<string>("externalUrl");

                    if (!string.IsNullOrEmpty(externalLink))

                        return externalLink;

                }

     

                return null;

            }

        } 

  • Donald Swofford 13 posts 107 karma points
    Aug 07, 2014 @ 16:07
    Donald Swofford
    0

    Thanks for the help!  301 worked great for me did exactly what I needed.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies