2

I have a site that has many URL rewrites and a good portion of them contain old links that are prefixed with a country code (e.g. /fr, /de, etc). Rewrites without the prefixes work just fine but those with trigger Sitecore's embedded language URL parser which bypasses the rewrite module entirely.

Example /fr/old-link tries to parse 'fr' as a language and fails as 'fr-FR' is the name of the French language.

Solution I need to disable Sitecore's ability to detect a language prefix in the URL so the URL rewrite module can proceed unhindered.

I can't find where it is in the pipeline that this occurs. I've gone through numerous with Reflector and come up short. I need help please.

2
  • I got some info on StripLanguage and URL resolvement here: partechit.nl/nl/blog/2014/03/… maybe it can help your case Commented Jun 26, 2014 at 8:27
  • Thank you, Ruud, I'll take a look shortly :) Commented Jun 26, 2014 at 8:36

2 Answers 2

1

Another pipeline to look at is the preprocessRequest pipeline. It has a StripLanguage processor that detects if the first part of the URL is a language and acts on it.

More info on how to get Sitecore to ignore the language part of the url can be found in this post http://sitecoreblog.patelyogesh.in/2013/11/sitecore-item-with-language-name.html

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, I'll take a look shortly :)
That was the one that was causing the problems. The rewrite module was affecting Sitecore in other ways so I kept the config file an wrote my own pipeline process to intercept the request and match it against any rewrites. Thanks to those who contributed.
1

You will need to create a new LanguageResolver to replace the standard Sitecore one (Sitecore.Pipelines.HttpRequest.LanguageResolver). This is referenced in the <httpRequestBegin> pipeline section in web.config. Here you can handle requests beginning with fr as opposed to fr-FR etc. In the past I have done a similar thing for when we wanted to use non-ISO language codes.

EDIT

The LanguageResolver resolves language based on query string first, but will also resolve based on file path (i.e. having fr-FR in the start of your path). I think you would need to inherit from the Sitecore LanguageResolver and override the GetLanguageFromRequest method changing the else statement to use something different to Context.Data.FilePathLanguage - possibly just using regex/string manipulation to get the first folder from the URL then use that to set the context language. This should prevent the failure to resolve language which I understand is killing your URL rewrite module.

3 Comments

Thanks for the reply, however that was the first processor I looked at but it only deals with the query string parameter method of changing context language, not the prefix before the item path. I need to intercept and 'skip over' that element of the pipeline only, the existing language resolver is fine as is.
@wardey please see my edits above. Hopefully this addresses your queries.
I hang my head in shame :) A proper woods-for-the-trees moment here. I've been spinning a lot of plates and must've overlooked it. Thanks much, jumping back onto this now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.