Jump to content

[SOLVED] FRIENDLY URL: How to customize them?


rv01

Recommended Posts

There is no way to change the format of friendly URLs without modifying code, so I don't think it is a good idea to do it unless it is really necessary. If it is, you can change line 45 of classes/Link.php from:

return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$lang_link.(($id_product->category != 'home' AND !empty($id_product->category)) ? $id_product->category.'/' : '').intval($id_product->id).'-'.$id_product->link_rewrite.($id_product->ean13 ? '-'.$id_product->ean13 : '').'.html') :



to:

return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$lang_link/*.(($id_product->category != 'home' AND !empty($id_product->category)) ? $id_product->category.'/' : '')*/.intval($id_product->id).'-'.$id_product->link_rewrite.($id_product->ean13 ? '-'.$id_product->ean13 : '').'.html') :



and line 48 from:

return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$lang_link.(($category AND $category != 'home') ? ($category.'/') : '').intval($id_product).'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') :



to:

return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$lang_link/*.(($category AND $category != 'home') ? ($category.'/') : '')*/.intval($id_product).'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') :

Link to comment
Share on other sites

  • 3 months later...

I see two differing opinions in the comments above. I have a question. Does it make any real difference to google and your keywords whether you use the home category or a sub category in your url?

For example:

http://www.gamesfromeverywhere.com.au/chess-sets/232-chess-set-polish-kings.html

and

http://www.gamesfromeverywhere.com.au/232-chess-set-polish-kings.html

Thanks.

Link to comment
Share on other sites

Gathered from many sources this is the summary for URL:

Keyword should be in URL, first place (so category or product number IS a nuisance!)
Keep it short, less than 50 char
Use hyphens to separate words
Use 2 or 3 hyphens
4 or more hyphens is bad.

So, again I say that putting the category number as the first word in the URLs is bad,
same when Prestashop puts the product number first,
because you should put the product name (= keyword) first.

Cheers

Link to comment
Share on other sites

Hi David,
I think you have to change the file ".htaccess" and re-order the URL rewriting rules lines.
I'll try on my local test instance of the shop to see if it's enough.

I would like a comment from a Prestashop specialist/moderator.

There are so many things "they" should put in the BO parameters to avoid us to change the code.
Even this forum text message editor looks quite old fashioned, is bugged and not user friendly,
and have strange behavior. (Beside, the forum is an absolute must).

Cheers,
Rene

Link to comment
Share on other sites

Hi David,
I removed the product id number in classes/link.php , URL building is OK but then the page is not found anymore.
It would be nice to put (in the URL construction) the product name before the product number,
but I don't know how to achieve this.
Can you try with a new post to ask specifically this?
Cheers

PS: removing the category worked well as explained here above.

Link to comment
Share on other sites

  • 5 months 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...