Jump to content

Cannot remove ".html" from product pages URLs in PrestaShop 1.5.3.0


Recommended Posts

In Schema of URLs / Route to products, I’ve changed the

 

{category:/}{id}-{rewrite}{-:ean13}.html

to

{category:/}{id}-{rewrite}{-:ean13}

 

but the product pages are still containing the “.html” at the end of the friendly URLs.

I have this issue after upgrading to PrestaShop 1.5.3.0 from 1.5.2.0 where the .html was not appearing in the product pages friendly URLs.

Any ideas how to fix this?

Cheers,

Adrian.

Link to comment
Share on other sites

  • 2 weeks later...

This is NOT ACCEPTABLE!!!

 

All of our hard SEO work is now totally wasted because PS1.5.3 destroys the URLS when upgraded.

 

If I find a solution I will post it. If not, I am going to waste hundreds of hours of work and miss a potentially very large income

Link to comment
Share on other sites

That is not a solution, that is the description of the cause of the problem.

 

I found a fix: backup classes/php and replace it with a copy of classes/dispatcher.php from version 1.5.2.

 

For now, it seems to work.

 

 

/////

 

SORRY :) I didnt see the actual fix due to the page scrolling down.

However, my fix works too.

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

  • 2 months later...

I hate to dredge up an older post but this is an issue for my shop (1.5.3.1). I moved the code as per instructions in the forge link and confirmed schema code in BO as indicated but still am getting .html on product pages. Did force compile, cleared cache, etc. but to no avail.

Any thoughts?

 

Solved:

Forge comment said:

P.S BO->Schema of URLs->Route to Product URL should be set as {categories:/}{id}-{rewrite}{-:ean13}.html

to make it work.

 

Instead - you should remove (as OP stated) .html from {categories:/}{id}-{rewrite}{-:ean13}.html

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

currently on the 1.5.3.1 the custom URL's do not work. i edited the Dispatcher.php itself (not the recommended way). I altered the default routes there and that worked. PS might of fixed it in the new version but i could not get the code in the forge to work properely either.

 

look at this thread http://www.prestashop.com/forums/topic/215984-schema-of-urls-not-updating/

Link to comment
Share on other sites

  • 2 weeks later...

Just saw this now - thanks for the link shoulders.

 

My urls are working now by combining the git code and editing the rewrite rule in the BO as indicated in my post above.

Now the only problem I have now is google is showing duplicate meta desc and titles in GWT not to mention over a 100 404's

because both the .html version and the non .html versions are showing up which is strange because trying to access the .html version of a page gives a 404 as expected so how is google seeing the .html version?

 

For example:

 

GATSBY Duvet Set - Whispar Design

 

url_icon.png/duvet-bedding/36-gatsby-duvet-set.html

 

url_icon.png/duvet-bedding/36-gatsby-duvet-set

 

I have tried a standard redirect rewrite rule in .htaccess for .html to non html but it didn't like it so I am not sure what to do next.

Link to comment
Share on other sites

  • 4 weeks later...
  • 7 months later...

I fixed it overriding Dispatcher :

 

override/classes/Dispatcher.php
 
<?php


class Dispatcher extends DispatcherCore
{
        /**
         * Load default routes group by languages
         */
        protected function loadRoutes()
        {
                $context = Context::getContext();


                // Load custom routes from modules
                $modules_routes = Hook::exec('moduleRoutes', array(), null, true, false);
                if (is_array($modules_routes) && count($modules_routes))
                foreach($modules_routes as $module_route)
                  foreach($module_route as $route => $route_details)
                    if (array_key_exists('controller', $route_details) && array_key_exists('rule', $route_details)
                      && array_key_exists('keywords', $route_details) && array_key_exists('params', $route_details))
                      {
                              if (!isset($this->default_routes[$route]))
                                $this->default_routes[$route] = array();
                              $this->default_routes[$route] = array_merge($this->default_routes[$route], $route_details);
                                }


                // Set default routes
                foreach (Language::getLanguages() as $lang)
                        foreach ($this->default_routes as $id => $route)
                                $this->addRoute(
                                        $id,
                                        $route['rule'],
                                        $route['controller'],
                                        $lang['id_lang'],
                                        $route['keywords'],
                                        isset($route['params']) ? $route['params'] : array()
                );


                // Load the custom routes prior the defaults to avoid infinite loops
                if ($this->use_routes)
                {
                        // Get iso lang
                        $iso_lang = Tools::getValue('isolang');
                        $id_lang = $context->language->id;
                        if (!empty($iso_lang))
                                $id_lang = Language::getIdByIso($iso_lang);


                        // Load routes from meta table
                        $sql = 'SELECT m.page, ml.url_rewrite, ml.id_lang
                                        FROM `'._DB_PREFIX_.'meta` m
                                        LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.Shop::addSqlRestrictionOnLang('ml').')
                                        ORDER BY LENGTH(ml.url_rewrite) DESC';
                        if ($results = Db::getInstance()->executeS($sql))
                                foreach ($results as $row)
                                {
                                        if ($row['url_rewrite'])
                                                $this->addRoute($row['page'], $row['url_rewrite'], $row['page'], $row['id_lang']);
                                }


                        // Set default empty route if no empty route (that's weird I know)
                        if (!$this->empty_route)
                                $this->empty_route = array(
                                        'routeID' =>    'index',
                                        'rule' =>               '',
                                        'controller' => 'index',
                                );


                        // Load custom routes
                        foreach ($this->default_routes as $route_id => $route_data)
                                if ($custom_route = Configuration::get('PS_ROUTE_'.$route_id))
                                        foreach (Language::getLanguages() as $lang)
                                                $this->addRoute(
                                                        $route_id,
                                                        $custom_route,
                                                        $route_data['controller'],
                                                        $lang['id_lang'],
                                                        $route_data['keywords'],
                                                        isset($route_data['params']) ? $route_data['params'] : array()
                                                );
                }




        }
}
Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...