Jump to content

Language folders in my shop URL


Recommended Posts

When ever I go to my website dekom.co.rs when it loads URL has language code folder added to URL like http://dekom.co.rs/sr/

 

What can I do to get only dekom.co.rs without /sr/ as my website will always be in one language.

 

Second questions is, how can I set both URL with and without www prefixt to be available as now when some goes for example http://dekom.co.rs/sr/[spam-filter]rezervni-delovi-za-klima-i-rashladne-uredjaje-u-kuci?controller=404 and add www prefix it will redirect website to 404 page.

 

If i type www.dekom.co.rs it redirects me ok to dekom.co.rs/sr/.

 

Ty in advance.

Dean

Link to comment
Share on other sites

If you have more than 1 language enabled in Prestashop, a /xx (xx is the language code) will be added.

 

You should disable any languages you do not use in Localization->Languages.

 

http://dekom.co.rs/sr/[spam-filter]rezervni-delovi-za-klima-i-rashladne-uredjaje-u-kuci?controller=404

will load a 404 page, as that is the controller name that's added to the URL.

 

You should pick a default URL (with, or without www), and use htaccess redirect to point one to the other (see an example at http://www.presto-changeo.com/en/content/6-prestashopseotips )

Link to comment
Share on other sites

Tomerg3,

 

Thanks for taking interest.

 

Yes, it seems like I didn't disable all the languages that I dont use in the front end. Now I have only Serbian language active, there are not /xx (country code) folder added and no language switcher feature enabled in the front end.

 

So far so good B)

 

When it comes to www or witout www, these are my current setting in the back office:

 

post-525426-0-92221200-1372318375_thumb.jpg

 

So these are set to dekom.co.rs

 

What I need to do is to use this tut you gave me to edit my httacces file right?

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

Update:

 

Is seems that when I disable all the languages except the one I want to have in my front end, and that is Serbian, non of my categories work as their addresses are left with the dekom.co.rs/sr/...

 

It gives me 404. When I enabled US English, categories were working again.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

My problem is same i have website and i want to enable english, when it is disabled and when i have only one leanguge it is going to my main http://artemisinin.rs

When i enable second leanguge it goes to http://artemisinin.rs/sr

I try htacces redirection but it is not working.

i am using prestashop 1.5.6.2 it is old but it has best stability an most of modules can be used on it.

 

Ok what we need is someone who know to write code in PHP.

Code tht he must write is in module blocklanguages file is blocklanguages.php

 

<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

if (!defined('_PS_VERSION_'))
    exit;

class BlockLanguages extends Module
{
    public function __construct()
    {
        $this->name = 'blocklanguages';
        $this->tab = 'front_office_features';
        $this->version = 1.1;
        $this->author = 'PrestaShop';
        $this->need_instance = 0;

        parent::__construct();

        $this->displayName = $this->l('Language block');
        $this->description = $this->l('Adds a block allowing customers to select a website language. ');
    }

    public function install()
    {
        return (parent::install() && $this->registerHook('top') && $this->registerHook('header'));
    }

    private function _prepareHook($params)
    {
        $languages = Language::getLanguages(true, $this->context->shop->id);
        if (!count($languages))
            return false;
        $link = new Link();

        if ((int)Configuration::get('PS_REWRITING_SETTINGS'))
        {
            $default_rewrite = array();
            if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int)Tools::getValue('id_product')))
            {
                $rewrite_infos = Product::getUrlRewriteInformations((int)$id_product);
                foreach ($rewrite_infos as $infos)
                    $default_rewrite[$infos['id_lang']] = $link->getProductLink((int)$id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int)$infos['id_lang']);
            }

            if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int)Tools::getValue('id_category')))
            {
                $rewrite_infos = Category::getUrlRewriteInformations((int)$id_category);
                foreach ($rewrite_infos as $infos)
                    $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int)$id_category, $infos['link_rewrite'], $infos['id_lang']);
            }

            if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int)Tools::getValue('id_cms')) || ($id_cms_category = (int)Tools::getValue('id_cms_category'))))
            {
                $rewrite_infos = (isset($id_cms) && !isset($id_cms_category)) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category);
                foreach ($rewrite_infos as $infos)
                {
                    $arr_link = (isset($id_cms) && !isset($id_cms_category)) ?
                        $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) :
                        $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']);
                    $default_rewrite[$infos['id_lang']] = $arr_link;
                }
            }
            $this->smarty->assign('lang_rewrite_urls', $default_rewrite);
        }
        return true;
    }


    /**
    * Returns module content for header
    *
    * @param array $params Parameters
    * @return string Content
    */
    public function hookTop($params)
    {
        if (!$this->_prepareHook($params))
            return;
        return $this->display(__FILE__, 'blocklanguages.tpl');
    }

    public function hookHeader($params)
    {
        $this->context->controller->addCSS($this->_path.'blocklanguages.css', 'all');
    }
}

 

 

It must be writen some excpetion from main leanguge in this case it is Serbian this will solwe problem. I am contacting few programers for this becouse like i see Prestashop dont want to give us this help. Seo score will drop a lot with this default leanguge doesnt need to be in some subfolder like it is in just one leanguge wen you use second this module starts to work.

Link to comment
Share on other sites

×
×
  • Create New...