blacksymmetry Posted March 29, 2011 Share Posted March 29, 2011 Hello I would like to remove Category ID from URL in PS 1.4.I tried: http://www.prestashop.com/forums/viewthread/2451/P90/third_party_modules/tools_url_rewriting__maj_1_dot_2Althought I installed on v1.4 , i cannot correctly use it.For example i have got category:frob.loc/1-my-category/ I tried in module BO:Uploaded with ImageShack.usBut if I type frob.loc/my-category/ Got error 404 Anybody know where could be a problem?Thanks for any advice 1 Link to comment Share on other sites More sharing options...
JJ Choo Posted October 24, 2011 Share Posted October 24, 2011 I'm looking for solution for this too.... Link to comment Share on other sites More sharing options...
subulica Posted March 28, 2012 Share Posted March 28, 2012 Any news about this problem ? Link to comment Share on other sites More sharing options...
subulica Posted March 30, 2012 Share Posted March 30, 2012 HELLLOOOOOOOOOOOOOOOOOOOOOOOOO Link to comment Share on other sites More sharing options...
daYmo Posted March 30, 2012 Share Posted March 30, 2012 Wow ... look like someone's getting aggressive over here ... Sure you can remove id from category link if you know how to manage url_rewriting in .htaccess file and you modify you class Link.php Link to comment Share on other sites More sharing options...
subulica Posted March 31, 2012 Share Posted March 31, 2012 Wow ... look like someone's getting aggressive over here ... Sure you can remove id from category link if you know how to manage url_rewriting in .htaccess file and you modify you class Link.php All of us know how to work from .htaccess and Link.php from classes but you dont know something. If we write more lines in .htaccess it will be huge and then the website will be more slowly. I`ll do that with few categories and is hard to do that for first and after this the real problem will be the .htaccess size be smart. Link to comment Share on other sites More sharing options...
daYmo Posted March 31, 2012 Share Posted March 31, 2012 don't have to make a rule for each category but you can manage it in one line in your .htaccess file and change 1 line too in your Link.php file in getCategoryLink function ... 1 Link to comment Share on other sites More sharing options...
subulica Posted March 31, 2012 Share Posted March 31, 2012 First i dont know how to do Link.php for presta 1.4.7.0 and if i do this with some specific categories what is happen with the rest of categories? Link to comment Share on other sites More sharing options...
daYmo Posted March 31, 2012 Share Posted March 31, 2012 All of us know how to work from .htaccess and Link.php from classes but you dont know something. If we write more lines in .htaccess it will be huge and then the website will be more slowly. I`ll do that with few categories and is hard to do that for first and after this the real problem will be the .htaccess size be smart. First i dont know how to do Link.php for presta 1.4.7.0 and if i do this with some specific categories what is happen with the rest of categories? Sorry but you know or you don't know ? For instance if you don't want the ID and you're selling ... cars for instance you can replace the URL http://www.mysite.com/23-category-rewrite http://www.mysite.com/cars/category-rewrite to do so ... add in your .htaccess file : RewriteRule ^cars/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] Then add a function to search for the id_category corresponding to this url link rewrite since you don't have the ID but the url link rewrite ! Then in your create a file override/classes/Link.php : <?php class Link extends LinkCore { public function getCategoryLink($id_category, $alias = NULL, $id_lang = NULL) { if (is_object($id_category)) return ($this->allow == 1) ? (_PS_BASE_URL_.__PS_BASE_URI__.'cars/'.$id_category->link_rewrite) : (_PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category->id)); if ($alias) return ($this->allow == 1) ? (_PS_BASE_URL_.__PS_BASE_URI__.'cars/'.$alias) : (_PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category)); return _PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category); } } ?> something like that ... Link to comment Share on other sites More sharing options...
subulica Posted March 31, 2012 Share Posted March 31, 2012 Sorry but you know or you don't know ? For instance if you don't want the ID and you're selling ... cars for instance you can replace the URL http://www.mysite.com/23-category-rewrite http://www.mysite.com/cars/category-rewrite to do so ... add in your .htaccess file : RewriteRule ^cars/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] Then add a function to search for the id_category corresponding to this url link rewrite since you don't have the ID but the url link rewrite ! Then in your create a file override/classes/Link.php : <?php class Link extends LinkCore { public function getCategoryLink($id_category, $alias = NULL, $id_lang = NULL) { if (is_object($id_category)) return ($this->allow == 1) ? (_PS_BASE_URL_.__PS_BASE_URI__.'cars/'.$id_category->link_rewrite) : (_PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category->id)); if ($alias) return ($this->allow == 1) ? (_PS_BASE_URL_.__PS_BASE_URI__.'cars/'.$alias) : (_PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category)); return _PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category); } } ?> something like that ... All done and many thanx but in override/classes/Link.php i can to insert all my categories like in .htaccess or si a single line for entire Link.php for all categories ? And other thing NOW I HAVE CATEGORY cars EVERYWHERE ) and my override/classes/Link.php look so : <?php class Link extends LinkCore { public function getCategoryLink($id_category, $alias = NULL, $id_lang = NULL) { if (is_object($id_category)) return ($this->allow == 1) ? (_PS_BASE_URL_.__PS_BASE_URI__.'reincarcari-cartuse-laserjet-si-inkjet/'.$id_category->link_rewrite) : (_PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category->id)); if ($alias) return ($this->allow == 1) ? (_PS_BASE_URL_.__PS_BASE_URI__.'reincarcari-cartuse-laserjet-si-inkjet/'.$alias) : (_PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category)); return _PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category); } } ?> and my .htaccess RewriteRule ^reincarcari-cartuse-laserjet-si-inkjet/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] RewriteRule ^laserjet-hp/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] RewriteRule ^laserjet-canon/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] RewriteRule ^laserjet-samsung/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] RewriteRule ^laserjet-dell/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] RewriteRule ^laserjet-xerox/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] RewriteRule ^laserjet-lexmark/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] RewriteRule ^laserjet-epson/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] RewriteRule ^laserjet-brother/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] I think this is the problem $1$2 but how i fix it for each category ? Link to comment Share on other sites More sharing options...
daYmo Posted March 31, 2012 Share Posted March 31, 2012 ok Sorry I don't have all the time necesary to explain all the process... It seems that it's too technical for you. or you didn't get what I said ... If you wanna remove category ID you'll have to use a pattern (like a word i"cars" in my example) which will be common to all the categories. Why ? so as to know that a url containing "/cars/....." refers to a category and there for the following is the link_rewrite of the category without the id. therefore ... instead of getiing directly the id in category.php ($_GET["id_category"]) you'll have to get the link_rewrite value : in my example $_GET["url_rewrite"] and searching for the categoy that correspond in the database to that link_rewrite. Good luck Link to comment Share on other sites More sharing options...
subulica Posted March 31, 2012 Share Posted March 31, 2012 ok Sorry I don't have all the time necesary to explain all the process... It seems that it's too technical for you. or you didn't get what I said ... If you wanna remove category ID you'll have to use a pattern (like a word i"cars" in my example) which will be common to all the categories. Why ? so as to know that a url containing "/cars/....." refers to a category and there for the following is the link_rewrite of the category without the id. therefore ... instead of getiing directly the id in category.php ($_GET["id_category"]) you'll have to get the link_rewrite value : in my example $_GET["url_rewrite"] and searching for the categoy that correspond in the database to that link_rewrite. Good luck I understand and escuse me ... in the end this will not help me with nothing. I appreciate your entire effort. But my problem is : 1) first i have for my domain name a wordpress with many many many products and categories and pages. 2) i decided to work with Prestashop 3) i want to keep my old links indexed from google 3) if i dont do that google will penalize me enormously because OLD LINK WAS www.mydomain.com/laser-jet and now is www.mydomain.com/5-laserjet. I would be very grateful if you could help me to do that. I get something in this post http://www.prestasho...__1#entry791743 but i dont know to modify the Link.php from classes for PS 1.4.7. Link to comment Share on other sites More sharing options...
subulica Posted April 2, 2012 Share Posted April 2, 2012 ok Sorry I don't have all the time necesary to explain all the process... It seems that it's too technical for you. or you didn't get what I said ... If you wanna remove category ID you'll have to use a pattern (like a word i"cars" in my example) which will be common to all the categories. Why ? so as to know that a url containing "/cars/....." refers to a category and there for the following is the link_rewrite of the category without the id. therefore ... instead of getiing directly the id in category.php ($_GET["id_category"]) you'll have to get the link_rewrite value : in my example $_GET["url_rewrite"] and searching for the categoy that correspond in the database to that link_rewrite. Good luck Please help me i really need it. If i do like you told me ... what is happen with others products and category newer added ? Is any way to make how you told me only with a few categories and products ? Link to comment Share on other sites More sharing options...
subulica Posted April 7, 2012 Share Posted April 7, 2012 Can i do this thing only with Products ???????? Link to comment Share on other sites More sharing options...
cara_ionutz Posted April 15, 2012 Share Posted April 15, 2012 Sorry but you know or you don't know ? For instance if you don't want the ID and you're selling ... cars for instance you can replace the URL http://www.mysite.com/23-category-rewrite http://www.mysite.com/cars/category-rewrite to do so ... add in your .htaccess file : RewriteRule ^cars/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] Then add a function to search for the id_category corresponding to this url link rewrite since you don't have the ID but the url link rewrite ! Then in your create a file override/classes/Link.php : <?php class Link extends LinkCore { public function getCategoryLink($id_category, $alias = NULL, $id_lang = NULL) { if (is_object($id_category)) return ($this->allow == 1) ? (_PS_BASE_URL_.__PS_BASE_URI__.'cars/'.$id_category->link_rewrite) : (_PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category->id)); if ($alias) return ($this->allow == 1) ? (_PS_BASE_URL_.__PS_BASE_URI__.'cars/'.$alias) : (_PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category)); return _PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category); } } ?> something like that ... I had tried what you said and i gett missing category error. can you please tell me what i should do ? Thank you Link to comment Share on other sites More sharing options...
daYmo Posted April 16, 2012 Share Posted April 16, 2012 what's the code of your function to get category id from url_rewrite in Category.php file ? And the code modified in category.php file to take into account this new parameter url_rewrite instead of id_category ? Link to comment Share on other sites More sharing options...
cara_ionutz Posted April 17, 2012 Share Posted April 17, 2012 what's the code of your function to get category id from url_rewrite in Category.php file ? And the code modified in category.php file to take into account this new parameter url_rewrite instead of id_category ? Sory for that but i modify the file classes/Link.php instead created the override/classes/link.php. But after i created ive add this <?php class Link extends LinkCore { public function getCategoryLink($id_category, $alias = NULL, $id_lang = NULL) { if (is_object($id_category)) return ($this->allow == 1) ? (_PS_BASE_URL_.__PS_BASE_URI__.'cars/'.$id_category->link_rewrite) : (_PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category->id)); if ($alias) return ($this->allow == 1) ? (_PS_BASE_URL_.__PS_BASE_URI__.'cars/'.$alias) : (_PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category)); return _PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category); } } ?> then ive add this line in htacces RewriteRule ^cars/([a-zA-Z0-9-+]*)(.*)$ category.php?url_rewrite=$1$2 [QSA,L,E] and ive got error 504 or 503 ive dont remember well. What ive done wrong? So can you please what should i do to add a word instead category id? thank you Link to comment Share on other sites More sharing options...
ctini Posted October 26, 2012 Share Posted October 26, 2012 Not solved? Link to comment Share on other sites More sharing options...
Recommended Posts