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.
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.
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");
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.
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
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;
}
}
Thanks for the help! 301 worked great for me did exactly what I needed.
is working on a reply...