Jump to content

Remove anchor from url


Recommended Posts

  • 2 weeks later...

Do we have function to automatically remove any junk or speical characters in URLs in prestashop?

Like we have function to remove sql injection when accepting data from form.


PrestaShop Tutorials Videos [How to do Tasks]

https://www.prestashop.com/forums/topic/907438-prestashop-tutorials-videos-how-to-do-tasks/

Edited by Zohaib-fk (see edit history)
Link to comment
Share on other sites

By default feature of PrestaShop in Preferences>SEO URLs removes the un-necessary characters from the urls. Only products ids will appears after turning it on. Although these IDs don't too much matter for SEO however, if you've requirement to remove them. You can use Pretty URLs Module of 3rd party. 

Link to comment
Share on other sites

  • 2 weeks later...

Hi I have similar issue as google bot  can't see the url beyond the hashtag

 

here is the warning from google merchant center

 

(In the URL for all your products you have a "#" sign. For eg. http://xtremewarehouse.com.au/1372-max-s-supersize.html#/size-4kg/flavour-banana/

 
The Google Reviewing software that reviews your data feed doesn't read description in the URL after the "#" symbol which is causing the discrepancy in prices)
 
Any idea what can be done please.
Link to comment
Share on other sites

  • 1 year later...

Indeed.

 

BUMP !

 

href lang issues arise since the urls in the alternate tags are not identical to the ones with the hashtag since google bot turns a blind eye to everything beyond the hash tag.

 

Solutions (without the use of modules please, I have plenty activated already) are welcome

Link to comment
Share on other sites

  • 2 years later...

Maybe it could help someone:

I need to replace "#" in url with "?selected_filter=" (to make infinite scroll working with layered navigation), so I changed in blocklayered.php (presta 1.6.1.20)

in line 2877

    $type_filter['values'][$key]['link'] = $categorie_link.'#'.ltrim($parameters, '/');

to

    $type_filter['values'][$key]['link'] = $categorie_link.'?selected_filters='.ltrim($parameters, '/');

in line 3185:

            'current_friendly_url' => ((int)$n == (int)$nb_products) ? '#/show-all': '#'.$filter_block['current_friendly_url'],

to

           'current_friendly_url' => ((int)$n == (int)$nb_products) ? '/show-all': '?selected_filters='.$filter_block['current_friendly_url'],

Try to simply remove "#" from those lines
Infinite scroll in block layered works fine for me now.
 

Link to comment
Share on other sites

Hello,

I would like to remove everything after and including the # hashtag from our urls on product pages with combinations. This is in Prestashop 1.7.

Prestashop 1.6 doesn't seem to have this problem.

For example, in 1.6, when a user clicks to a product (product page) with combinations the URL is like this:

www.website.com/product-category/67-product.html

However, and I need to fix this, on Prestashop 1.7 the URL is like so:

www.website.com/product-category/67-product.html#/301-product-color

 

This is when the user first comes to page. In PS 1.6 it just has www.website.com/product-category/67-product.html and then once the user picked a combination it would change to www.website.com/product-category/67-product.html#/301-product-color which is fine.

When a user first comes to product page in 1.7 it automatically shows www.website.com/product-category/67-product.html#/301-product-color

How can I get rid of the #/301-product-color when the page is first loaded up?

 

I hope this makes sense.

 

I have the feeling this is really hurting our SEO, as our shops in 1.6 seem to rank very well, however, in 1.7 everything that has a hashtag on the end seems to do poorly as far as SEO is concerned.

Anybody that has any ideas please let me know!

 

Thanks

 

 

 

Link to comment
Share on other sites

  • 10 months later...

in /override/classes/Link.php

I change this and it's ok now. 

        /** return $url . $dispatcher->createUrl('product_rule', $idLang, array_merge($params, $extraParams), $force_routes, $anchor, $idShop);*/
        return $url . $dispatcher->createUrl('product_rule', $idLang, array_merge($params, $extraParams), $force_routes, $idShop);
 

I'm currently testing it.  if there is some news I'll write here. 

Link to comment
Share on other sites

I found this as well

 

https://stackoverflow.com/questions/49531603/prestashop-1-7-remove-hash-1-size-4-from-url

 

// $anchor = $ipa ? $product->getAnchor((int) $ipa, (bool) $addAnchor) : ''; // <-- Here is the change

  $anchor = '';


  return $url . $dispatcher->createUrl('product_rule', $idLang, array_merge($params, $extraParams), $force_routes, $anchor, $idShop);

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