Jump to content

[Help] Remove Category ID from URL


Recommended Posts

Pierre-Yves wrote a nice solution. Thanks, Pierre-Yves! It is a hack in that it messes with the prestashop core files, but that's what one must do for now. There are some other issues you might run into.

There are three relevant files on the page:
1) The module that automatically sets up the .htaccess file - urlrewritingplus_1_2.zip
2) The modifications to link.php - be careful here as the attached file is for prestashop 1.0, not 1.1 - however, the additions to the file still work fine as written
3) There is also in the thread the module translated (mostly) into english

Link to comment
Share on other sites

would you explain with more details how it's done ? i read that post but i;m not so good in french.
i tested but still no changes made. same as before.
prestashop v1.1

in blockcategories i can find that line which makes that change

Link to comment
Share on other sites

Some instructions in English for using the urlrewritingplus module.

1) Download the file urlrewritingplus_1_2.zip from the thread, and unzip to the main modules directory
2) Download urlrewritingplus.php from the fourth page. This is the same module translated to English. Replace the old urlrewritingplus.php in the modules/urlrewritingplus directory with this one.
3) Download link.php from the first page, but don't use this one directly. Instead,
4) Open up the file classes/link.php and replace the functions "public function getProductLink" and "public function getCategoryLink" with those same functions from the link.php file you downloaded.
5) Go into the admin panel. Under modules, install and configure urlrewritingplus to Create the Rules for all products and categories, and then to Generate the Rules. You might want to backup your .htaccess file before doing this.

Hope that's helpful!

Link to comment
Share on other sites

I haven't tried to change the url rewrite for anything but the products and categories, but I imagine that you could extend the solutions by modifying the getCMSLink function in link.php just as you modified getCategoryLink and getProductLink (except that it ought to be more simple) and adding a new button to the urlrewritingplus module to support CMS. Same goes for getSupplierLink, getManufacturerLink, and so on.

Let us know if you have some success extending it!

Link to comment
Share on other sites

I didn't understand what you were asking the first time, but here's an actual answer. To fix the error on the cms links when using the urlrewritingplus module:

Go to the admin panel. Click on modules and configure for urlrewritingplus.
At the bottom you'll see "File. Htaccess default". Click on the text field to edit.
Add this line: RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ cms.php?id_cms=$1 [QSA,L,E]
Click on the button, "Save the file content .htaccess default".
Click on "Generate Rules"

That should do it. It just gives you the normal Prestashop Friendly URLs for the cms, but it does work...

Link to comment
Share on other sites

sorry to inform that it doesn't work that way. seems that i have to modify the link.php at the "public function getCMSLink"

with the standard modfication as you explain it to me works fine for products and categories.

but

when i click on a cms returns server error page not found on server or resticted.


i do not what to insert a new tab in the module.
i just want to make it work without errors.

cheers !

Link to comment
Share on other sites

  • 3 weeks later...
The menu is a module, so you can just override the module template by copying /modules/blockcategories/*.tpl in /themes/yourtheme/modules/blockcategories/*.tpl and remove the id in the links.


I don't know what you say 'couse in my case there's no modules folder in theme directory

I have the same issue with the category number, I don't found anything to remove that number.

I'm using prestashop 1.0
Link to comment
Share on other sites

  • 6 months later...
  • 4 months later...

Iam rewriting urls manually while Pierre-Yves solution appears to be outdated.
I cant figure is how to remove id from tpl file as suggested below.

The menu is a module, so you can just override the module template by copying /modules/blockcategories/*.tpl in /themes/yourtheme/modules/blockcategories/*.tpl and remove the id in the links.

What would be required code modification?
Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...
  • 8 months later...
Yop

RewriteRule ^computers$ category.php?id_category=3 [QSA,L,E]
RewriteRule ^lcds/dell-lcd$ category.php?id_category=4 [QSA,L,E]


I add this in my .htacces and i also have modified file link.php
but it shows 500 internal server error.

any solution? i'm working on this in my local server, not in any hosting.
Thanks
Link to comment
Share on other sites

  • 10 months later...
  • 1 month later...
  • 2 months later...

 

 

I add this in my .htacces and i also have modified file link.php

but it shows 500 internal server error.

 

any solution? i'm working on this in my local server, not in any hosting.

Thanks

it works for me but only in site but my old links from google wont work

Link to comment
Share on other sites

  • 2 years later...
  • 3 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...