Jump to content

Remove /en/ from URL when multi language enstalled


TheCoffeeLocator

Recommended Posts

Hi,

I developed my site in English only. When adding a language:

  • /it/ gets added in urls for italian (ok)
  • /en/ gets added for english (not ok)

I want to get rid of the /en/ from english URLs. htaccess is the obviuous solution, but this gets rewritten, so I woulcd forever have to update.

 

Does anyone know where this is actually added in the code, or a way of removing?

 

Thanks

Link to comment
Share on other sites

Thanks @Damonsk. I located the area of code:

 

// Classic URL rewriting
if ($rewrite_settings)
foreach ($tab['RewriteRule']['content'] as $rule => $url)
 fwrite($writeFd, 'RewriteRule '.$rule.' '.__PS_BASE_URI__.$url."\n");

 

and added a few lines:

 

// Classic URL rewriting
if ($rewrite_settings)
foreach ($tab['RewriteRule']['content'] as $rule => $url)
 fwrite($writeFd, 'RewriteRule '.$rule.' '.__PS_BASE_URI__.$url."\n");
 fwrite($writeFd, "RewriteRule ^en/(.*)$ /$1 [L,R=301]\n");
 fwrite($writeFd, "RewriteRule ^market/en(.*)$ /market$1 [L,R=301]\n");

 

But not working! Does anyone have any ideas?

Link to comment
Share on other sites

You may have to re-generate the htaccess file - this is done in the back office. Either SEO/URLS for 1.5 and Generators in 1.4.

 

Could you copy/paste the generated htaccess file by prestashop and provide an example of what you would like the htaccess to look like. I'll see if I can help more.

Link to comment
Share on other sites

Thanks Damonsk, much appreciated.

I have regenerated the htaccess. This was not the problem. Below is the htaccess generated when 2 lanbguages are set, the bottom few lines were my attempt to overwrite the /en/ folder!

 

<IfModule mod_rewrite.c>
# URL rewriting module activation
RewriteEngine on
# URL rewriting rules
RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1-$2$3.jpg [L]
RewriteRule ^([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1-$2.jpg [L]
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$1$2.jpg [L]
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$1$2$3.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$3/$1$2$3$4.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteRule ^c/([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /market/img/c/$1$2.jpg [L]
RewriteRule ^c/([a-zA-Z-]+)/[a-zA-Z0-9-]+\.jpg$ /market/img/c/$1.jpg [L]
RewriteRule ^c/([0-9]+)/[a-zA-Z0-9-]+\.jpg$ /market/img/c/$1.jpg [L]
RewriteRule ^([a-z]{2})/[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html /market/product.php?id_product=$2&isolang=$1 [QSA,L]
RewriteRule ^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*\.html /market/product.php?id_product=$2&isolang=$1 [QSA,L]
RewriteRule ^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+ /market/category.php?id_category=$2&isolang=$1&noredirect=1 [QSA,L]
RewriteRule ^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]* /market/category.php?id_category=$2&isolang=$1 [QSA,L]
RewriteRule ^([a-z]{2})/content/([0-9]+)\-[a-zA-Z0-9-]* /market/cms.php?isolang=$1&id_cms=$2 [QSA,L]
RewriteRule ^([a-z]{2})/content/category/([0-9]+)\-[a-zA-Z0-9-]* /market/cms.php?isolang=$1&id_cms_category=$2 [QSA,L]
RewriteRule ^([a-z]{2})/([0-9]+)__[a-zA-Z0-9-]* /market/supplier.php?isolang=$1&id_supplier=$2 [QSA,L]
RewriteRule ^([a-z]{2})/([0-9]+)_[a-zA-Z0-9-]* /market/manufacturer.php?isolang=$1&id_manufacturer=$2 [QSA,L]
RewriteRule ^([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /market/img/c/$1$2.jpg [L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]*\.html /market/product.php?id_product=$1 [QSA,L]
RewriteRule ^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html /market/product.php?id_product=$1 [QSA,L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+ /market/category.php?id_category=$1&noredirect=1 [QSA,L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]* /market/category.php?id_category=$1 [QSA,L]
RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*) /market/supplier.php?id_supplier=$1 [QSA,L]
RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*) /market/manufacturer.php?id_manufacturer=$1 [QSA,L]
RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*) /market/cms.php?id_cms=$1 [QSA,L]
RewriteRule ^content/category/([0-9]+)\-([a-zA-Z0-9-]*) /market/cms.php?id_cms_category=$1 [QSA,L]
RewriteRule ^([a-z]{2})/vendor/name-start-with-([a-zA-Z]*) /market/modules/agilesellerproducts/agilesellers.php?filter=$2 [QSA,L]
RewriteRule ^([a-z]{2})/vendor/([0-9]+)\-([a-zA-Z0-9-]*) /market/modules/agilesellerproducts/agileseller.php?id_seller=$2&seller_name=$3 [QSA,L]
RewriteRule ^([a-z]{2})/countries/([0-9]+)\-([a-zA-Z0-9-]*) /market/modules/agilesellerproducts/sellercountry.php?id_seller_country=$2 [QSA,L]
RewriteRule ^vendor/name-start-with-([a-zA-Z]*) /market/modules/agilesellerproducts/agilesellers.php?filter=$1 [QSA,L]
RewriteRule ^vendor/([0-9]+)\-([a-zA-Z0-9-]*) /market/modules/agilesellerproducts/agileseller.php?id_seller=$1&seller_name=$2 [QSA,L]
RewriteRule ^countries/([0-9]+)\-([a-zA-Z0-9-]*) /market/modules/agilesellerproducts/sellercountry.php?id_seller_country=$1 [QSA,L]
RewriteRule ^([a-z]{2})/seller /market//modules/agilemultipleseller/myselleraccount.php [QSA,L]
RewriteRule ^seller /market//modules/agilemultipleseller/myselleraccount.php [QSA,L]
RewriteRule ^en/page-not-found$ /market/404.php?isolang=en [QSA,L]
RewriteRule ^en/address$ /market/address.php?isolang=en [QSA,L]
RewriteRule ^en/addresses$ /market/addresses.php?isolang=en [QSA,L]
RewriteRule ^en/authentication$ /market/authentication.php?isolang=en [QSA,L]
RewriteRule ^en/best-sales$ /market/best-sales.php?isolang=en [QSA,L]
RewriteRule ^en/cart$ /market/cart.php?isolang=en [QSA,L]
RewriteRule ^en/contact-us$ /market/contact-form.php?isolang=en [QSA,L]
RewriteRule ^en/discount$ /market/discount.php?isolang=en [QSA,L]
RewriteRule ^en/guest-tracking$ /market/guest-tracking.php?isolang=en [QSA,L]
RewriteRule ^en/order-history$ /market/history.php?isolang=en [QSA,L]
RewriteRule ^en/identity$ /market/identity.php?isolang=en [QSA,L]
RewriteRule ^en/manufacturers$ /market/manufacturer.php?isolang=en [QSA,L]
RewriteRule ^en/my-account$ /market/my-account.php?isolang=en [QSA,L]
RewriteRule ^en/new-products$ /market/new-products.php?isolang=en [QSA,L]
RewriteRule ^en/order$ /market/order.php?isolang=en [QSA,L]
RewriteRule ^en/order-follow$ /market/order-follow.php?isolang=en [QSA,L]
RewriteRule ^en/quick-order$ /market/order-opc.php?isolang=en [QSA,L]
RewriteRule ^en/order-slip$ /market/order-slip.php?isolang=en [QSA,L]
RewriteRule ^en/password-recovery$ /market/password.php?isolang=en [QSA,L]
RewriteRule ^en/prices-drop$ /market/prices-drop.php?isolang=en [QSA,L]
RewriteRule ^en/search$ /market/search.php?isolang=en [QSA,L]
RewriteRule ^en/sitemap$ /market/sitemap.php?isolang=en [QSA,L]
RewriteRule ^en/stores$ /market/stores.php?isolang=en [QSA,L]
RewriteRule ^en/supplier$ /market/supplier.php?isolang=en [QSA,L]
RewriteRule ^en$ /market/en/ [QSA,L]
RewriteRule ^en/([^?&]*)$ /market/$1?isolang=en [QSA,L]
RewriteRule ^it/pagina-non-trovata$ /market/404.php?isolang=it [QSA,L]
RewriteRule ^it/indirizzo$ /market/address.php?isolang=it [QSA,L]
RewriteRule ^it/indirizzi$ /market/addresses.php?isolang=it [QSA,L]
RewriteRule ^it/autenticazione$ /market/authentication.php?isolang=it [QSA,L]
RewriteRule ^it/vendite-migliori$ /market/best-sales.php?isolang=it [QSA,L]
RewriteRule ^it/carrello$ /market/cart.php?isolang=it [QSA,L]
RewriteRule ^it/contattaci$ /market/contact-form.php?isolang=it [QSA,L]
RewriteRule ^it/sconto$ /market/discount.php?isolang=it [QSA,L]
RewriteRule ^it/ospite-monitoraggio$ /market/guest-tracking.php?isolang=it [QSA,L]
RewriteRule ^it/storico-ordine$ /market/history.php?isolang=it [QSA,L]
RewriteRule ^it/identita$ /market/identity.php?isolang=it [QSA,L]
RewriteRule ^it/produttori$ /market/manufacturer.php?isolang=it [QSA,L]
RewriteRule ^it/il-mio-account$ /market/my-account.php?isolang=it [QSA,L]
RewriteRule ^it/nuovi-prodotti$ /market/new-products.php?isolang=it [QSA,L]
RewriteRule ^it/ordine$ /market/order.php?isolang=it [QSA,L]
RewriteRule ^it/seguito-ordine$ /market/order-follow.php?isolang=it [QSA,L]
RewriteRule ^it/ordine-veloce$ /market/order-opc.php?isolang=it [QSA,L]
RewriteRule ^it/nota-di-ordine$ /market/order-slip.php?isolang=it [QSA,L]
RewriteRule ^it/password-recupero$ /market/password.php?isolang=it [QSA,L]
RewriteRule ^it/riduzione-prezzi$ /market/prices-drop.php?isolang=it [QSA,L]
RewriteRule ^it/cerca$ /market/search.php?isolang=it [QSA,L]
RewriteRule ^it/sitemap$ /market/sitemap.php?isolang=it [QSA,L]
RewriteRule ^it/negozi$ /market/stores.php?isolang=it [QSA,L]
RewriteRule ^it/fornitore$ /market/supplier.php?isolang=it [QSA,L]
RewriteRule ^it$ /market/it/ [QSA,L]
RewriteRule ^it/([^?&]*)$ /market/$1?isolang=it [QSA,L]
RewriteRule ^en/(.*)$ /$1 [L,R=301]
RewriteRule ^market/en(.*)$ /market$1 [L,R=301]
</IfModule>

Link to comment
Share on other sites

Thankyou very much Damonsk - legend! I think I just did it... well almost. The code below strips out the en, but it seems to continualy redirect now to the italian subfolder!

 

Original code:

protected function getLangLink($id_lang = NULL)
{
 if (!$this->allow || Language::countActiveLanguages() <= 1)
  return '';

 global $cookie;
 if (!$id_lang) $id_lang = (int)$cookie->id_lang;
 return Language::getIsoById((int)$id_lang).'/';
}

 

Mod to remove the en:

protected function getLangLink($id_lang = NULL)
{
 if (!$this->allow || Language::countActiveLanguages() <= 1)
  return '';

 global $cookie;
 if (!$id_lang) $id_lang = (int)$cookie->id_lang;
 if (Language::getIsoById((int)$id_lang)=='en') return '';
 else return Language::getIsoById((int)$id_lang).'/';
}

Edited by TheCoffeeLocator (see edit history)
Link to comment
Share on other sites

It's probably been set in the cookie. Modify the generate htaccess in tools and append &isolang=en to the end of the none multilang urls.

Sorry I dont follow. In tools generate htaccess, most urls have the &isolang= at the end - see below

 

public static function generateHtaccess($path, $rewrite_settings, $cache_control, $specific = '', $disableMultiviews = false)
{
 $tab = array('ErrorDocument' => array(), 'RewriteEngine' => array(), 'RewriteRule' => array());
 $multilang = (Language::countActiveLanguages() > 1);
 // ErrorDocument
 $tab['ErrorDocument']['comment'] = '# Catch 404 errors';
 $tab['ErrorDocument']['content'] = '404 '.__PS_BASE_URI__.'404.php';
 // RewriteEngine
 $tab['RewriteEngine']['comment'] = '# URL rewriting module activation';
 // RewriteRules
 $tab['RewriteRule']['comment'] = '# URL rewriting rules';
 // Compatibility with the old image filesystem
 if (Configuration::get('PS_LEGACY_IMAGES'))
 {
  $tab['RewriteRule']['content']['^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$'] = _PS_PROD_IMG_.'$1-$2$3.jpg [L]';
  $tab['RewriteRule']['content']['^([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-]*\.jpg$'] = _PS_PROD_IMG_.'$1-$2.jpg [L]';
 }
 // Rewriting for product image id < 100 millions
 $tab['RewriteRule']['content']['^([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$'] = _PS_PROD_IMG_.'$1/$1$2.jpg [L]';
 $tab['RewriteRule']['content']['^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$'] = _PS_PROD_IMG_.'$1/$2/$1$2$3.jpg [L]';
 $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$'] = _PS_PROD_IMG_.'$1/$2/$3/$1$2$3$4.jpg [L]';
 $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$'] = _PS_PROD_IMG_.'$1/$2/$3/$4/$1$2$3$4$5.jpg [L]';
 $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$'] = _PS_PROD_IMG_.'$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg [L]';
 $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$'] = _PS_PROD_IMG_.'$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg [L]';
 $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$'] = _PS_PROD_IMG_.'$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg [L]';
 $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$'] = _PS_PROD_IMG_.'$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg [L]';
 $tab['RewriteRule']['content']['^c/([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$'] = 'img/c/$1$2.jpg [L]';
 $tab['RewriteRule']['content']['^c/([a-zA-Z-]+)/[a-zA-Z0-9-]+\.jpg$'] = 'img/c/$1.jpg [L]';
 $tab['RewriteRule']['content']['^c/([0-9]+)/[a-zA-Z0-9-]+\.jpg$'] = 'img/c/$1.jpg [L]';
 if ($multilang)
 {
  $tab['RewriteRule']['content']['^([a-z]{2})/[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$2&isolang=$1&noredirect=1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/content/([0-9]+)\-[a-zA-Z0-9-]*'] = 'cms.php?isolang=$1&id_cms=$2 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/content/category/([0-9]+)\-[a-zA-Z0-9-]*'] = 'cms.php?isolang=$1&id_cms_category=$2 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)__[a-zA-Z0-9-]*'] = 'supplier.php?isolang=$1&id_supplier=$2 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)_[a-zA-Z0-9-]*'] = 'manufacturer.php?isolang=$1&id_manufacturer=$2 [QSA,L]';
 }
 // PS BASE URI automaticaly prepend the string, do not use PS defines for the image directories
 $tab['RewriteRule']['content']['^([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$'] = 'img/c/$1$2.jpg [L]';
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$1 [QSA,L]';
 $tab['RewriteRule']['content']['^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$1 [QSA,L]';
 // Notice : the id_category rule has to be after product rules.
 // If not, category with number in their name will result a bug
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$1&noredirect=1 [QSA,L]';
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$1 [QSA,L]';
 $tab['RewriteRule']['content']['^([0-9]+)__([a-zA-Z0-9-]*)'] = 'supplier.php?id_supplier=$1 [QSA,L]';
 $tab['RewriteRule']['content']['^([0-9]+)_([a-zA-Z0-9-]*)'] = 'manufacturer.php?id_manufacturer=$1 [QSA,L]';
 $tab['RewriteRule']['content']['^content/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms=$1 [QSA,L]';
 $tab['RewriteRule']['content']['^content/category/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms_category=$1 [QSA,L]';
 // Compatibility with the old URLs
 if (!Configuration::get('PS_INSTALL_VERSION') OR version_compare(Configuration::get('PS_INSTALL_VERSION'), '1.4.0.7') == -1)
 {
  // This is a nasty copy/paste of the previous links, but with "lang-en" instead of "en"
  // Do not update it when you add something in the one at the top, it's only for the old links
  $tab['RewriteRule']['content']['^lang-([a-z]{2})/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html'] = 'product.php?id_product=$3&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'category.php?id_category=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^content/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^content/category/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms_category=$1 [QSA,L]';
 }
 Language::loadLanguages();
 $default_meta = Meta::getMetasByIdLang((int)_PS_LANG_DEFAULT_);
 if ($multilang)
  foreach (Language::getLanguages() as $language)
  {
   foreach (Meta::getMetasByIdLang($language['id_lang']) as $key => $meta)
 if (!empty($meta['url_rewrite']) AND Validate::isLinkRewrite($meta['url_rewrite']))
  $tab['RewriteRule']['content']['^'.$language['iso_code'].'/'.$meta['url_rewrite'].'$'] = $meta['page'].'.php?isolang='.$language['iso_code'].' [QSA,L]';
   elseif (array_key_exists($key, $default_meta) && $default_meta[$key]['url_rewrite'] != '')
 $tab['RewriteRule']['content']['^'.$language['iso_code'].'/'.$default_meta[$key]['url_rewrite'].'$'] = $default_meta[$key]['page'].'.php?isolang='.$language['iso_code'].' [QSA,L]';
   $tab['RewriteRule']['content']['^'.$language['iso_code'].'$'] = $language['iso_code'].'/ [QSA,L]';
   $tab['RewriteRule']['content']['^'.$language['iso_code'].'/([^?&]*)$'] = '$1?isolang='.$language['iso_code'].' [QSA,L]';
  }
 else
  foreach ($default_meta as $key => $meta)
   if (!empty($meta['url_rewrite']))
 $tab['RewriteRule']['content']['^'.$meta['url_rewrite'].'$'] = $meta['page'].'.php [QSA,L]';
 elseif (array_key_exists($key, $default_meta) && $default_meta[$key]['url_rewrite'] != '')
  $tab['RewriteRule']['content']['^'.$default_meta[$key]['url_rewrite'].'$'] = $default_meta[$key]['page'].'.php [QSA,L]';
 if (!$writeFd = @fopen($path, 'w'))
  return false;
 // PS Comments
 fwrite($writeFd, "# .htaccess automaticaly generated - DONT MODIFY MANUALLY - use HTACCESS GENERATOR IN BACK OFFICE\n");
 fwrite($writeFd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
 if (!empty($specific))
  fwrite($writeFd, $specific);
 // RewriteEngine
 fwrite($writeFd, "\n<IfModule mod_rewrite.c>\n");
 if ($disableMultiviews)
  fwrite($writeFd, "\n# Disable Multiviews\nOptions -Multiviews\n\n");
 fwrite($writeFd, $tab['RewriteEngine']['comment']."\nRewriteEngine on\n\n");
 fwrite($writeFd, $tab['RewriteRule']['comment']."\n");
 // Webservice
 if (Configuration::get('PS_WEBSERVICE'))
 {
  fwrite($writeFd, 'RewriteRule ^api/?(.*)$ '.__PS_BASE_URI__."webservice/dispatcher.php?url=$1 [QSA,L]\n");
  if (Configuration::get('PS_WEBSERVICE_CGI_HOST'))
   fwrite($writeFd, 'RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]'."\n");
 }
// Classic URL rewriting
if ($rewrite_settings)
foreach ($tab['RewriteRule']['content'] as $rule => $url)
 fwrite($writeFd, 'RewriteRule '.$rule.' '.__PS_BASE_URI__.$url."\n");
 fwrite($writeFd, "RewriteRule ^en/(.*)$ /$1 [L,R=301]\n");
 fwrite($writeFd, "RewriteRule ^market/en(.*)$ /market$1 [L,R=301]\n");

 fwrite($writeFd, "</IfModule>\n\n");
 // ErrorDocument
 fwrite($writeFd, $tab['ErrorDocument']['comment']."\nErrorDocument ".$tab['ErrorDocument']['content']."\n");
 // Cache control
 if ($cache_control)
 {
  fwrite($writeFd, '
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 year"
</IfModule>
FileETag INode MTime Size
<IfModule mod_deflate.c>
<IfModule mod_filter.c>
 AddOutputFilterByType DEFLATE text/html text/css text/plain text/javascript application/javascript application/x-javascript
</IfModule>
</IfModule>'."\n");
 }
 fclose($writeFd);
 Module::hookExec('afterCreateHtaccess');
 return true;
}

Link to comment
Share on other sites

You may have to regenerate the htaccess once you modify tools class.

 

The problem here is when you visit the site intiially your set to the default language - english. When you navigate away to a url with the isocode for italy the language in your cookie is updated. So if you visit a site without the language set within the url it will just load from your cookie.

 

If you see there is a test to see if your shop is using languages - if($multilang) . This then creates new urls for each language. What needs to be done or added into your htaccess is urls without the language set but actually set on the rewrite rule.

 

 

$tab['RewriteRule']['content']['^([a-z]{2})/[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';

 

 

 

You can see the first part of the rule is ([a-z]{2})/ this is the iso language code. This is then accepted as the $1 parameter in the product.php?id_product=$2&isolang=$1

 

So what is required is these rules without the first part ([a-z]{2}) but retains the isolang=

 

Example

 

 

$tab['RewriteRule']['content']['^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$1&isolang=en [QSA,L]';

 

 

These rules already exists immediately after the if($multilang) condition. So you need to amend these to include the isolang=en querystring.

  • Like 1
Link to comment
Share on other sites

You would amend rules outside the if($multilang) condition. The rules within the if($multilang) condition would need to remain as is so they load the correct language.

 

This won't have any impact on loading speeds.

 

 

if ($multilang)
 {
   // DO NOT CHANGE THESE
  $tab['RewriteRule']['content']['^([a-z]{2})/[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$2&isolang=$1&noredirect=1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/content/([0-9]+)\-[a-zA-Z0-9-]*'] = 'cms.php?isolang=$1&id_cms=$2 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/content/category/([0-9]+)\-[a-zA-Z0-9-]*'] = 'cms.php?isolang=$1&id_cms_category=$2 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)__[a-zA-Z0-9-]*'] = 'supplier.php?isolang=$1&id_supplier=$2 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)_[a-zA-Z0-9-]*'] = 'manufacturer.php?isolang=$1&id_manufacturer=$2 [QSA,L]';
 }
 // PS BASE URI automaticaly prepend the string, do not use PS defines for the image directories
 $tab['RewriteRule']['content']['^([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$'] = 'img/c/$1$2.jpg [L]';
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$1&isolang=en [QSA,L]';
 $tab['RewriteRule']['content']['^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$1&isolang=en [QSA,L]';
 // Notice : the id_category rule has to be after product rules.
 // If not, category with number in their name will result a bug
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$1&noredirect=1&isolang=en [QSA,L]';
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$1&isolang=en [QSA,L]';
 $tab['RewriteRule']['content']['^([0-9]+)__([a-zA-Z0-9-]*)'] = 'supplier.php?id_supplier=$1&isolang=en [QSA,L]';
 $tab['RewriteRule']['content']['^([0-9]+)_([a-zA-Z0-9-]*)'] = 'manufacturer.php?id_manufacturer=$1&isolang=en [QSA,L]';
 $tab['RewriteRule']['content']['^content/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms=$1&isolang=en [QSA,L]';
 $tab['RewriteRule']['content']['^content/category/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms_category=$1&isolang=en [QSA,L]';
 // Compatibility with the old URLs

 

 

Notice the &isolang=en appended to the urls above.

Link to comment
Share on other sites

Sure. I double check everything, and the following all give 404s:

 

login area, registration, new-products.php, search results, and many multistore features (this site is also a multishop where anyone can create a shop and sell).

 

<IfModule mod_rewrite.c>
# URL rewriting module activation
RewriteEngine on
# URL rewriting rules
RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1-$2$3.jpg [L]
RewriteRule ^([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1-$2.jpg [L]
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$1$2.jpg [L]
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$1$2$3.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$3/$1$2$3$4.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /market/img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteRule ^c/([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /market/img/c/$1$2.jpg [L]
RewriteRule ^c/([a-zA-Z-]+)/[a-zA-Z0-9-]+\.jpg$ /market/img/c/$1.jpg [L]
RewriteRule ^c/([0-9]+)/[a-zA-Z0-9-]+\.jpg$ /market/img/c/$1.jpg [L]
RewriteRule ^([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /market/img/c/$1$2.jpg [L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]*\.html /market/product.php?id_product=$1&isolang=en [QSA,L]
RewriteRule ^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html /market/product.php?id_product=$1&isolang=en [QSA,L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+ /market/category.php?id_category=$1&isolang=en&noredirect=1 [QSA,L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]* /market/category.php?id_category=$1&isolang=en [QSA,L]
RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*) /market/supplier.php?id_supplier=$1&isolang=en [QSA,L]
RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*) /market/manufacturer.php?id_manufacturer=$1&isolang=en [QSA,L]
RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*) /market/cms.php?id_cms=$1&isolang=en [QSA,L]
RewriteRule ^content/category/([0-9]+)\-([a-zA-Z0-9-]*) /market/cms.php?id_cms_category=$1&isolang=en [QSA,L]
RewriteRule ^([a-z]{2})/vendor/name-start-with-([a-zA-Z]*) /market/modules/agilesellerproducts/agilesellers.php?filter=$2 [QSA,L]
RewriteRule ^([a-z]{2})/vendor/([0-9]+)\-([a-zA-Z0-9-]*) /market/modules/agilesellerproducts/agileseller.php?id_seller=$2&seller_name=$3 [QSA,L]
RewriteRule ^([a-z]{2})/countries/([0-9]+)\-([a-zA-Z0-9-]*) /market/modules/agilesellerproducts/sellercountry.php?id_seller_country=$2 [QSA,L]
RewriteRule ^vendor/name-start-with-([a-zA-Z]*) /market/modules/agilesellerproducts/agilesellers.php?filter=$1 [QSA,L]
RewriteRule ^vendor/([0-9]+)\-([a-zA-Z0-9-]*) /market/modules/agilesellerproducts/agileseller.php?id_seller=$1&seller_name=$2 [QSA,L]
RewriteRule ^countries/([0-9]+)\-([a-zA-Z0-9-]*) /market/modules/agilesellerproducts/sellercountry.php?id_seller_country=$1 [QSA,L]
RewriteRule ^([a-z]{2})/seller /market//modules/agilemultipleseller/myselleraccount.php [QSA,L]
RewriteRule ^seller /market//modules/agilemultipleseller/myselleraccount.php [QSA,L]
RewriteRule ^page-not-found$ /market/404.php [QSA,L]
RewriteRule ^address$ /market/address.php [QSA,L]
RewriteRule ^addresses$ /market/addresses.php [QSA,L]
RewriteRule ^authentication$ /market/authentication.php [QSA,L]
RewriteRule ^best-sales$ /market/best-sales.php [QSA,L]
RewriteRule ^cart$ /market/cart.php [QSA,L]
RewriteRule ^contact-us$ /market/contact-form.php [QSA,L]
RewriteRule ^discount$ /market/discount.php [QSA,L]
RewriteRule ^guest-tracking$ /market/guest-tracking.php [QSA,L]
RewriteRule ^order-history$ /market/history.php [QSA,L]
RewriteRule ^identity$ /market/identity.php [QSA,L]
RewriteRule ^manufacturers$ /market/manufacturer.php [QSA,L]
RewriteRule ^my-account$ /market/my-account.php [QSA,L]
RewriteRule ^new-products$ /market/new-products.php [QSA,L]
RewriteRule ^order$ /market/order.php [QSA,L]
RewriteRule ^order-follow$ /market/order-follow.php [QSA,L]
RewriteRule ^quick-order$ /market/order-opc.php [QSA,L]
RewriteRule ^order-slip$ /market/order-slip.php [QSA,L]
RewriteRule ^password-recovery$ /market/password.php [QSA,L]
RewriteRule ^prices-drop$ /market/prices-drop.php [QSA,L]
RewriteRule ^search$ /market/search.php [QSA,L]
RewriteRule ^sitemap$ /market/sitemap.php [QSA,L]
RewriteRule ^stores$ /market/stores.php [QSA,L]
RewriteRule ^supplier$ /market/supplier.php [QSA,L]
RewriteRule ^en/(.*)$ /$1 [L,R=301]
RewriteRule ^market/en(.*)$ /market$1 [L,R=301]
</IfModule>
# Catch 404 errors
ErrorDocument 404 /market/404.php

Link to comment
Share on other sites

Do you have this setup on a dev / test server that I could view?

 

Also are the 404's generated by language urls (url.com/it/search) or limited to say just your english version (url.com/search). I can see the rule is present for url.com/search but not for specific languages url.com/it/search.

Link to comment
Share on other sites

  • 2 weeks later...

@damonsk

 

I have implemented Your solution in Prestashop 1.5.

 

I have overridden the link class's getLanglink() function. But now the problem is that once a user goes into some other language, he/she can not bounce back to English.

 

I have seen in the post that you have recommended changes for Prestashop 1.4 in tools::gethtaccess function. What changes should i do in prestashop 1.5.

 

Also can you guide me to put the language option at the end of the URL.... like www.example.com/about-us/br/

Link to comment
Share on other sites

  • 3 months later...

@darktangent the solution works to an extent. But I also have the issue of not being able to switch back languages (in ps 1.4).

 

How did you get on with this - did you manage to get it to work? Please let me know as i'm keen to do the same.

 

I would like to enable other languages but keep english as the default without it affecting my urls and seo, i dont mind if the other languages are within folders for de or fr etc as they will be new pages.

Link to comment
Share on other sites

We stil have the language issues:

  • Some pages users cannot change language
  • Some pages do not have multilanguage (due to modules we installed not having language settings)

Though we have no tlooked into the issue for a while now. when we get the solution we will post here as it is valuable

  • Like 1
Link to comment
Share on other sites

We stil have the language issues:

  • Some pages users cannot change language
  • Some pages do not have multilanguage (due to modules we installed not having language settings)

Though we have no tlooked into the issue for a while now. when we get the solution we will post here as it is valuable

 

Thanks for the update - There were quite a few previous posts would you mind clarifying what you did in the end to stop "/en/" being used for english?

 

Thanks a lot.

Link to comment
Share on other sites

Thanks for the update - There were quite a few previous posts would you mind clarifying what you did in the end to stop "/en/" being used for english?

 

Thanks a lot.

It is a shame that prestashop does not have an option to do this built into the back end when a user adds a language:

 

Post #5 - rewrite the .htaccess file. Any line that refers to "agile" you will not need - this is an addon module that we used to create a marketplace. You will have to change the links as well to suit your store.

 

Post #8 - to remove the /en/ from english language.

 

Be careful as any errors in htaccess ccan cause your site to show stop working. make sure you backup the files on server before making these changes.

  • Like 1
Link to comment
Share on other sites

ok i'm struggling to get it to work.

 

I've tried modifying Link.php to this:-

protected function getLangLink($id_lang = NULL)
{
  if (!$this->allow || Language::countActiveLanguages() <= 1)
   return '';

  global $cookie;
  if (!$id_lang) $id_lang = (int)$cookie->id_lang;
  if (Language::getIsoById((int)$id_lang)=='en') return '';
  else return Language::getIsoById((int)$id_lang).'/';
}

 

I also modified Tools.php to append &isolang=en

 

if ($multilang)
 {
  $tab['RewriteRule']['content']['^([a-z]{2})/[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$2&isolang=$1&noredirect=1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/content/([0-9]+)\-[a-zA-Z0-9-]*'] = 'cms.php?isolang=$1&id_cms=$2 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/content/category/([0-9]+)\-[a-zA-Z0-9-]*'] = 'cms.php?isolang=$1&id_cms_category=$2 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)__[a-zA-Z0-9-]*'] = 'supplier.php?isolang=$1&id_supplier=$2 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)_[a-zA-Z0-9-]*'] = 'manufacturer.php?isolang=$1&id_manufacturer=$2 [QSA,L]';
 }
 // PS BASE URI automaticaly prepend the string, do not use PS defines for the image directories
 $tab['RewriteRule']['content']['^([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$'] = 'img/c/$1$2.jpg [L]';
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$1&isolang=en [QSA,L]';
 $tab['RewriteRule']['content']['^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$1&isolang=en [QSA,L]';
 // Notice : the id_category rule has to be after product rules.
 // If not, category with number in their name will result a bug
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$1&noredirect=1&isolang=en [QSA,L]';
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$1&isolang=en [QSA,L]';
 $tab['RewriteRule']['content']['^([0-9]+)__([a-zA-Z0-9-]*)'] = 'supplier.php?id_supplier=$1&isolang=en [QSA,L]';
 $tab['RewriteRule']['content']['^([0-9]+)_([a-zA-Z0-9-]*)'] = 'manufacturer.php?id_manufacturer=$1&isolang=en [QSA,L]';
 $tab['RewriteRule']['content']['^content/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms=$1&isolang=en [QSA,L]';
 $tab['RewriteRule']['content']['^content/category/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms_category=$1&isolang=en [QSA,L]';
 // Compatibility with the old URLs
 if (!Configuration::get('PS_INSTALL_VERSION') OR version_compare(Configuration::get('PS_INSTALL_VERSION'), '1.4.0.7') == -1)
 {
  // This is a nasty copy/paste of the previous links, but with "lang-en" instead of "en"
  // Do not update it when you add something in the one at the top, it's only for the old links
  $tab['RewriteRule']['content']['^lang-([a-z]{2})/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html'] = 'product.php?id_product=$3&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'category.php?id_category=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^content/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^content/category/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms_category=$1 [QSA,L]';
 }

 

 

Have i missed something else?

Link to comment
Share on other sites

  • 2 months later...

We stil have the language issues:

  • Some pages users cannot change language
  • Some pages do not have multilanguage (due to modules we installed not having language settings)

Though we have no tlooked into the issue for a while now. when we get the solution we will post here as it is valuable

 

Could you list pages where users wasn't able to change language? I just remove default langauge identifier from URL following your posts and had problem just with homepage - had to add one more rule to htaccess RewriteRule ^$ /index.php?isolang=en [QSA,L]

Everything else works (or at least looks like it is working ;) )

Link to comment
Share on other sites

  • 1 year later...
  • 6 months later...

Hi at all.

I have 2 language in my store.

Italian (default) and english.

i See that for each language is possible to have this url:

shop.domain.com

shop.domain.com/it

shop.domain.com/it/

 

shop.domain.com

shop.domain.com/en

shop.domain.com/en/

 

What i would is to have only one url for each language.

for italian: shop.domain.com/it/

for english: shop.domain.com/en/

 

Ho can i fix this by .htaccess ?

 

Thank you at all for support.

Link to comment
Share on other sites

  • 5 months later...
  • 2 months later...
  • 4 months later...
  • 4 years later...

first of all: backup!

 

then:

  1. disable the languages don't used
  2. open .htaccess and add this code before "# Dispatcher" (if you have only en and it lang)

    RewriteRule ^en/(.*)$ /$1 [R=301,L]

    RewriteRule ^it/(.*)$ /$1 [R=301,L]

  3. save and upload the edited .htaccess

  4. TIP: regenerate the sitemap!

 

Matteo

Link to comment
Share on other sites

  • 1 year later...

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
×
×
  • Create New...