Default language url

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 anos atrás
Hi,
I have 2 languages on website:
1.domain.com/default-lang/
2.domain.com/sec-lang/

How can I change so default langunage will have no language will look like so:
domain.com (no language name after)

Thanks
8 anos atrás
forgot to mention:
and the second language will have lang name in url (domain.com/sec-lang)
8 anos atrás
Motmot wrote:
Hi,
I have 2 languages on website:
1.domain.com/default-lang/
2.domain.com/sec-lang/

How can I change so default langunage will have no language will look like so:
domain.com (no language name after)

Thanks


Hi,

this is not possible out of the box. You need to customize the source code of the nopCommerce in order to achieve what you want.

If you are willing to customize, you can start with a few things - version 3.70:

1). When a customer changes a language in your site, you need to check if the language is the default one and if so, you need to skip adding the SEO code to the URL. Open "\Presentation\Nop.Web\Controllers\CommonController.cs", find this:

returnUrl = returnUrl.AddLanguageSeoCodeToRawUrl(applicationPath, _workContext.WorkingLanguage)


and replace it with this:

if (_workContext.WorkingLanguage.Id != 1)
{
  returnUrl = returnUrl.AddLanguageSeoCodeToRawUrl(applicationPath, _workContext.WorkingLanguage);
}


*** Where "1" is the Id of your default language.

2) Open "\Presentation\Nop.Web.Framework\LanguageSeoCodeAttribute.cs", find this:

var workContext = EngineContext.Current.Resolve<IWorkContext>();


and add this code below it:

if (workContext.WorkingLanguage.Id == 1)
{
  return;
}


*** Where "1" is, again, the Id of your default language.

Hope this helps!
4 anos atrás
Maybe this should be an option in the admin ... is very usefull to limit the nr of redirects
1 ano atrás
Hi
In 2022 still works like this.
Without activating the option "SEO friendly URLs with multiple languages enabled" the urls don't change when you change language in a store.

The canonical url and all other info do change language but not the url.

Is this the expected behavior in nop 4.50.2?

Best
Jose
1 ano atrás
Nop-Templates.com wrote:
Hi,
I have 2 languages on website:
1.domain.com/default-lang/
2.domain.com/sec-lang/

How can I change so default langunage will have no language will look like so:
domain.com (no language name after)

Thanks

Hi,

this is not possible out of the box. You need to customize the source code of the nopCommerce in order to achieve what you want.

If you are willing to customize, you can start with a few things - version 3.70:

1). When a customer changes a language in your site, you need to check if the language is the default one and if so, you need to skip adding the SEO code to the URL. Open "\Presentation\Nop.Web\Controllers\CommonController.cs", find this:

returnUrl = returnUrl.AddLanguageSeoCodeToRawUrl(applicationPath, _workContext.WorkingLanguage)


and replace it with this:

if (_workContext.WorkingLanguage.Id != 1)
{
  returnUrl = returnUrl.AddLanguageSeoCodeToRawUrl(applicationPath, _workContext.WorkingLanguage);
}


*** Where "1" is the Id of your default language.

2) Open "\Presentation\Nop.Web.Framework\LanguageSeoCodeAttribute.cs", find this:

var workContext = EngineContext.Current.Resolve<IWorkContext>();


and add this code below it:

if (workContext.WorkingLanguage.Id == 1)
{
  return;
}


*** Where "1" is, again, the Id of your default language.

Hope this helps!


Can anyone put this on a plug in or widget so common users can have this feature?
Best
Jose
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.