Jump to content

how to remove main language in URL?


nest4
 Share

Recommended Posts

 

Hi Prestashopers,

 

I enabled another language in my store and now is:

 

mitienda.com/es/producto-01

mitienda.com/en/producto-01

 

I tried to remove the primary language (/es) of the URLs. The URLS /es to URLs /en if it works, but of /en to /es not working.

 

On the subject of SEO, I would like it to be:

 

mitienda.com/producto-01

mitienda.com/en/producto-01

 

any solution?

 

Best regards :)

Share this post


Link to post
Share on other sites

at the moment it is not possible. prestashop does not have feature to remove language indicator from url.

here, on forums you can find many posts related to your question, each of them is without answer / solution.

 

it's because this kind of change requires VERY LARGE and complex modification of prestashop core.

  • Like 1

Share this post


Link to post
Share on other sites

The current SEO trend is to actually expand your language url.  en-gb|en-us|es-es|es-ar|etc.

 

[Module] International Language Detect & SEO Friendly URL  This module is compatible with PrestaShop sitemap so that your URL's are indexed by lang/count(geo).  Now it is possible to have an es for example across multiple countries, before we could only have one es, as an example.  

 

So the idea is to not remove the language but to use 'best practice' with an expanded langue url.

 

for idea of how it works see my shop, but also see how is works on a website like Microsoft Azure.

 

Happy day, el

Share this post


Link to post
Share on other sites

  • 3 years later...

Hi community, good morning,

We have detected that suddenly we have a subfolder of language or country (/es/) in our domain:

our domain yesterday: https://example.com/

our domain today: https://example.com/es/

and we have not activated any multi store or multi language option in Prestashop.

301 redirects have been automatically set up and sitemaps have been automatically updated last night with new URLs. 

Do you know what could have happened? Do you think it can be harmful to Google and have any SEO risks?

Thank you,

Share this post


Link to post
Share on other sites

someone added spanish language pack or it was enabled, we have never seen it just happen without human intervention.

is there a disabled spanish language pack in languages?

it's more helpful to post prod url you can delete it later by editing the post

Share this post


Link to post
Share on other sites

2 hours ago, El Patron said:

someone added spanish language pack or it was enabled, we have never seen it just happen without human intervention.

is there a disabled spanish language pack in languages?

it's more helpful to post prod url you can delete it later by editing the post

Thanks for your reply! :)

Apparently English language pack/ translation was activated by someone and this have automatically generated the /es/ folder for Spanish URLs. 

We have disabled English translation and everything has gone back to normal. 

I hope it's ok and we would not see any SEO harm from Google. 🙏

Anyone here know if it can have some benefits to activate this feature if we could possibly have different languages in our store in the near future?

Thanks everyone!  

Share this post


Link to post
Share on other sites

check addon's, the key is to not change the 'default' url, for example if default is en, then you add enable other language, not displaying the /en/uri.

see addons' there are number of friendly url's, one (you will need to look) allows you to surpress default language, in this example /en/, but it will use other language(s) in url.

I don't however recommend using 'other' friendly url features, 1) changes core 2) can create issues when it comes to later upgrade.....

happy selling!

Share this post


Link to post
Share on other sites

9 hours ago, El Patron said:

check addon's, the key is to not change the 'default' url, for example if default is en, then you add enable other language, not displaying the /en/uri.

see addons' there are number of friendly url's, one (you will need to look) allows you to surpress default language, in this example /en/, but it will use other language(s) in url.

I don't however recommend using 'other' friendly url features, 1) changes core 2) can create issues when it comes to later upgrade.....

happy selling!

Gracias for your reply!

I have found this addon which seems to be pretty good for this:

https://addons.prestashop.com/en/url-redirects/16633-pretty-urls-remove-ids-numbers-for-seo-friendly-url.html

 

Share this post


Link to post
Share on other sites

5 hours ago, flormolla said:

Gracias for your reply!

I have found this addon which seems to be pretty good for this:

https://addons.prestashop.com/en/url-redirects/16633-pretty-urls-remove-ids-numbers-for-seo-friendly-url.html

 

that is the module we use for some customers, fme is good developer and does remove the default shop language...i'm have never been convinced removing ids from cat/prod/etc has any value, friendly url was introduced so customers could read the url to business over the phone...who does that now?  lol

happy selling

el

Share this post


Link to post
Share on other sites

  • 3 months later...

Hello, for 1.7 there is a way to remove the default languaje suffix in the URL when multiple languajes are active.

Create an override for link.php

And replace 

return Language::getIsoById($idLang) . '/';

WITH:

if (Language::getIsoById($idLang) === 'es') {
return '';
} else {
return Language::getIsoById($idLang) . '/';
}

 

WHERE 'es' is the languaje you want to remove from URL. The rest of languajes will put the suffix in the URL, like /en  /fr /it

 

The only problem is that if you change languaje you cannot return to the default (cookie stuff)

The solution to that is here: https://presta.site/blog/en/how-to-remove-en-from-urls-in-prestashop/#comment-54357  but i havent manage to make it works

 

Regards!

Share this post


Link to post
Share on other sites

  • 11 months later...

Can i get an answer to this issue i have.

 

safetynigeria.com/en is still the same as safetynigeria.com just that, initial, my store has two languages which are English(safetynigeria.com/en) and French(safetynigeria.com/fr). but now I installed i new version of my store and migrate all data only on one language which makes the domain to be only safetynigeria.com

so, Google has indexed many links and bookmarks. now I want to redirect so that the links can be updated. because if old url is used, it has a 404 page.

any help please? 

Share this post


Link to post
Share on other sites

  • 9 months later...

It seems to work for mee after I did an additional change to the changes suggested above in LInk.php class .

The additional change I did was in ovveride Tools function switchLanguage:

from:
 

        if (
            ($iso = Tools::getValue('isolang')) &&
            Validate::isLanguageIsoCode($iso) &&
            ($id_lang = (int) Language::getIdByIso($iso))
        ) {
            $_GET['id_lang'] = $id_lang;
        }

to

        if (
            ($iso = Tools::getValue('isolang')) &&
            Validate::isLanguageIsoCode($iso) &&
            ($id_lang = (int) Language::getIdByIso($iso))
        ) {
            $_GET['id_lang'] = $id_lang;
        }
        else {
            $_GET['id_lang'] = (int) Configuration::get('PS_LANG_DEFAULT');
        }

basically adding the else block to handle when there is no isolang posted:

else {

$_GET['id_lang'] = (int) Configuration::get('PS_LANG_DEFAULT');

}

I hope that helps the community.

 

Share this post


Link to post
Share on other sites

  • 3 months later...
On 2/15/2022 at 11:27 PM, LuckyMe said:

It seems to work for mee after I did an additional change to the changes suggested above in LInk.php class .

The additional change I did was in ovveride Tools function switchLanguage:

from:
 

        if (
            ($iso = Tools::getValue('isolang')) &&
            Validate::isLanguageIsoCode($iso) &&
            ($id_lang = (int) Language::getIdByIso($iso))
        ) {
            $_GET['id_lang'] = $id_lang;
        }

to

        if (
            ($iso = Tools::getValue('isolang')) &&
            Validate::isLanguageIsoCode($iso) &&
            ($id_lang = (int) Language::getIdByIso($iso))
        ) {
            $_GET['id_lang'] = $id_lang;
        }
        else {
            $_GET['id_lang'] = (int) Configuration::get('PS_LANG_DEFAULT');
        }

basically adding the else block to handle when there is no isolang posted:

else {

$_GET['id_lang'] = (int) Configuration::get('PS_LANG_DEFAULT');

}

I hope that helps the community.

 

Please let me know which file did you make the above change?

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More