In one of my older projects I made a usercontrol and added it to the default website. This usercontrol checked the language settings of the browser or using one of the free IP databases, with these details it made a redirect using C# code to the localised website.
I am unsure whether there exists a better way of doing it, but it worked for me. I would not make a permanent redirect though.
private string GetUrl()
{
var ip = Request.UserHostAddress;
var remoteCountry = LookupService.getCountry(ip);
var remoteCountryCode = (remoteCountry ?? new Country("--", "--")).getCode();
var country = CountryRepository.GetByCode(remoteCountryCode);
if (country == null)
{
return DefaultWebsiteUrl();
}
var websiteCultureCode = ContractService.GetValidContract(country.WebsiteCulture);
var node = _websiteCultureService.GetWebsite(websiteCultureCode);
var url = library.NiceUrl(node.Id);
Trace.Write("Redirecting - IP: " + ip + " is from " + remoteCountryCode + ", redirecting to: " + url);
return url;
}
Permanent Redirection in Umbraco
Can someone explains how to make a permanent redirection in umbraco when working with Multilingual Website?
Hi. I suspect that http://our.umbraco.org/projects/developer-tools/301-moved-permanently is more or less what you want.
Hi Rodion, this seems to be a good solution. Have you try it before? What Type do you use in your documentType when using it "TextString" ?
Am not sure this is working. What I need to do is a permanent Redirection.
That is when i type something like this in my browser
http://www.website.com it redirects me to http://www.website.com/en or http://www.website.com/en/
In one of my older projects I made a usercontrol and added it to the default website. This usercontrol checked the language settings of the browser or using one of the free IP databases, with these details it made a redirect using C# code to the localised website.
I am unsure whether there exists a better way of doing it, but it worked for me. I would not make a permanent redirect though.
Perhaps this blogpost can help: http://cultiv.nl/blog/2010/12/19/tip-of-the-week-the-ultimate-site-structure-setup/. The comments are also useful.
Jeroen
Hey Jeroen Thanks for the the blogpost. Got it working by using this in my UrlRewriting.config
//fuji
is working on a reply...