we created multilingual website in FR, ES, EN from old classic asp website( which was also in 3 languages). In Old site by default in English language "en" was not embedding in the URL. but in our new sitecore website i have language Embedding="Always".
So when we redirect from old website to new website for 301 redirects in Google, if i opened my new website in French language and redirect from old site is in English ( which means that in the url there is no language i.e "en") link will point to french version).
So how could i add "en" to the url .
HttpContext.Current.Request.RawUrl
i can use above to get the raw url but i am not getting how to display "en" in the browser url.
old website links:
www.abc.com/xyz.asp,
www.abc.com/fr/xyz.asp,
www.abc.com/es/xyz.asp
new website links:
www.abc.com/en/xyz.aspx,
www.abc.com/fr/xyz.aspx,
www.abc.com/es/xyz.aspx
thanks
How did you handle the language in the old website? How did you know a user was requesting a page in EN/FR/ES?
Since you are redirecting with a 301 from your old site you need to handle the language embedding into the URL from your old site. Handling it from the Sitecore side will add best only give you a "prettier" URL, with the added downside of having to add in another 302 redirect to the same page after you have inspected with the redirecting has the language embedded or not. Ruud's suggestion to use IIS Rewrite is a good one.
So when we redirect from old website to new website for 301 redirects in Google, if i opened my new website in French language and redirect from old site is in English ( which means that in the url there is no language i.e "en") link will point to french version).
Yes, this is how Sitecore works, it uses cookies to persist the last selected language, but context language is set in the following order. Your initial visit would set the language cookie.
Overriding Sitecore’s Logic to Determine the Context Language
If you really don't want the language persisted between browser sessions then override the Sitecore.Pipelines.HttpRequest.LanguageResolver
pipeline with your own logic to either NOT set the cookie (in which case you are totally relying on the request URL) OR set a cookie that will expire when the browser is closed. You can find an example from this blog post as well as an example in the previously linked John West blog post.
If your only concern is Google indexing, then I would probably not make any changes except add in a canonical link tags on your pages with the full URL including language (this will obviously be different for each language version).
<link rel="canonical" href="http://www.abc.com/en/xyz.aspx"/>