Jump to content
krat

Friendly urls without ID number?

Recommended Posts

FREE module available now:

http://www.prestashop.com/forums/index.php?/topic/110922-friendly-urls-without-id-number/page__view__findpost__p__883380

 

Here is what i got:

 

1st file: ./controllers/ProductController.php

 

update the function preProcess()

public function preProcess()
{
 if ($id_product = (int)Tools::getValue('id_product'))
  { $this->product = new Product($id_product, true, self::$cookie->id_lang); }
 else //remove link id by Ha!*!*y
 {
  $id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_lang`
WHERE `link_rewrite` = \''.Tools::getValue('product_name_seo').'\'');
  $this->product = new Product($id_product, true, self::$cookie->id_lang);
 } //remove link id by Ha!*!*y
 if (!Validate::isLoadedObject($this->product))
 {
  header('HTTP/1.1 404 Not Found');
  header('Status: 404 Not Found');
 }
 else
  $this->canonicalRedirection();
 parent::preProcess();
}

 

 

2nd file: ./classes/Link.php

 

update the function getProductLink()

public function getProductLink($id_product, $alias = NULL, $category = NULL, $ean13 = NULL, $id_lang = NULL)
{
 global $cookie;
 if (is_object($id_product))
 {
  $link = '';
  if ($this->allow == 1)
  {
$link .= (_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang));

if (isset($id_product->category) AND !empty($id_product->category) AND $id_product->category != 'home')
 $link .= $id_product->category.'/';
else
 $link .= '';
//remove link id by Ha!*!*y
//$link .= (int)$id_product->id.'-';
if (is_array($id_product->link_rewrite))
 $link.= $id_product->link_rewrite[(int)$cookie->id_lang];
else
  $link.= $id_product->link_rewrite;
if ($id_product->ean13)
 $link .='-'.$id_product->ean13;
else
 $link .= '';
$link .= '.html';
  }
  else
  {
$link .= (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product->id);
  }
  return $link;
 }

 else if ($alias)
 {
  $link = '';
  if ($this->allow == 1)
  {
$link .= (_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang));

if ($category AND $category != 'home')
 $link .= $category.'/';
else
  $link .= '';
//remove link id by Ha!*!*y
//$link .= (int)$id_product.'-'.$alias;
$link .= $alias;

if ($ean13)
 $link .='-'.$ean13;
else
 $link .= '';

$link .= '.html';
  }
  else
$link .=(_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product);
  return $link;
 }

 else
  return _PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product;
}

 

3rd file: ./classes/Tools.php

 

update the function generateHtaccess()

 

find inside the function

 if ($multilang)
 {
  $tab['RewriteRule']['content']['^([a-z]{2})/[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
  $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';

 

and add the following lines:

//remove link id by Ha!*!*y
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-z]{2})/[a-zA-Z0-9-]*/([a-zA-Z0-9-]*)\.html product.php?product_name_seo=$2&isolang=$1 [QSA,L]';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-z]{2})/([a-zA-Z0-9-]*)\.html product.php?product_name_seo=$2&isolang=$1 [QSA,L]';
//remove link id by Ha!*!*y

 

also look for inside the function:

 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$1 [QSA,L]';
 $tab['RewriteRule']['content']['^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$1 [QSA,L]';

 

 

and than add the following lines:

//remove link id by Ha!*!*y
	$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
	$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
	$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*)\.html product.php?product_name_seo=$1 [QSA,L]';
	$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
	$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
	$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^[a-zA-Z0-9-]*/([a-zA-Z0-9-]*)\.html product.php?product_name_seo=$1 [QSA,L]';
//remove link id by Ha!*!*y

 

also look for inside the function:

 // Classic URL rewriting
 if ($rewrite_settings)
  foreach ($tab['RewriteRule']['content'] as $rule => $url)
fwrite($writeFd, 'RewriteRule '.$rule.' '.__PS_BASE_URI__.$url."\n");

 

add this after:

//remove link id by Ha!*!*y
 if ($rewrite_settings){
  fwrite($writeFd, "\n");
  foreach ($tab['RewriteEngine']['content_no_id'] as $line => $rule){
fwrite($writeFd, $rule."\n");
  }
 }
//remove link id by Ha!*!*y
Edited by HA!*!*Y

Share this post


Link to post
Share on other sites

Hi HA!*!*Y

 

This solution has side effects:

 

All product metadata don't appearing and the title of page products show a default shop title.

 

You can fix this?, apart from this problem everything works fine

 

Thanks

 

Rysiu

Share this post


Link to post
Share on other sites

FREE module available now:

http://www.prestashop.com/forums/index.php?/topic/110922-friendly-urls-without-id-number/page__view__findpost__p__883380

 

i am look into it right now

 

this is a temporary solutions to the problem

 

Add this at the end of file: ./config/config.inc.php

 //remove link id by Ha!*!*y
 if (Tools::getValue('product_name_seo'))
 {
  $id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
	SELECT `id_product`
	FROM `'._DB_PREFIX_.'product_lang`
	WHERE `link_rewrite` = \''.Tools::getValue('product_name_seo').'\'');
  $_GET['id_product'] = $id_product;
 }

Edited by HA!*!*Y

Share this post


Link to post
Share on other sites

Works partially on my 1.4.5... It does remove the ID from products, but not from my categories and neither CMS links.. Any idea why ?? however it did the most important thing... remove the ID from products.. Thanks.

Share this post


Link to post
Share on other sites

This also worked partially for me.

 

It removes the ID's from product URL's, but it doesn't update all my URL's automatically, so all my links to products are broken.

 

Do I need to do something to my htaccess file to do that?

Share this post


Link to post
Share on other sites

FREE module available now:

http://www.prestashop.com/forums/index.php?/topic/110922-friendly-urls-without-id-number/page__view__findpost__p__883380

 

This also worked partially for me.

 

It removes the ID's from product URL's, but it doesn't update all my URL's automatically, so all my links to products are broken.

 

Do I need to do something to my htaccess file to do that?

 

Yes Go to:

Back Office > Tools > Generators

 

Generate your ".htaccess" file by clicking the button

Edited by HA!*!*Y

Share this post


Link to post
Share on other sites

FREE module available now:

http://www.prestashop.com/forums/index.php?/topic/110922-friendly-urls-without-id-number/page__view__findpost__p__883380

 

Works partially on my 1.4.5... It does remove the ID from products, but not from my categories and neither CMS links.. Any idea why ?? however it did the most important thing... remove the ID from products.. Thanks.

 

C.Perez, i did not update the code to remove IDs from categories or CMS link ill try to post that some time

Edited by HA!*!*Y

Share this post


Link to post
Share on other sites

Yes Go to:

Back Office > Tools > Generators

 

Generate your ".htaccess" file by clicking the button

 

Thanks for your reply HA!*!*Y.

 

I did try regenerating my htaccess file from the back-office, but it didn't work.

 

Could that be due to permissions on the file on the server? If I CHMOD the htaccess file to 777 will that work?

Share this post


Link to post
Share on other sites

Is there any progress in getting this to work for categories and subcategories? I had a bash at it myself, using your amends as a basis but unfortunately my dev skills don't seem up to the job as it didn't work! I edited the Link.php, Tools.php and config file but wasn't sure if anything needed changing in the ProductController, so perhaps that's where the issue lies...

 

edit - Just realised it's the CategoryController file that needs editing, not ProductController of course. Unfortunately still not working so must be missing something?

Edited by emma_w

Share this post


Link to post
Share on other sites

FREE module available now:

http://www.prestashop.com/forums/index.php?/topic/110922-friendly-urls-without-id-number/page__view__findpost__p__883380

 

 

To remove number from Category URL

 

1st file: ./controllers/CategoryController.php

 

update the function preProcess()

public function preProcess()
{
	if ($id_category = (int)Tools::getValue('id_category'))
		{ $this->category = new Category($id_category, self::$cookie->id_lang); }
	else //remove link id by Ha!*!*y
	{
		$id_category = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
			SELECT `link_rewrite`
			FROM `'._DB_PREFIX_.'category_lang`
			WHERE `link_rewrite` = \''.Tools::getValue('category_name_seo').'\'');
		$this->category = new Category($id_category, self::$cookie->id_lang);
	} //remove link id by Ha!*!*y
....

 

2nd file: ./classes/Link.php

 

update the function getCategoryLink

I removed (int)($id_category->id).'-'. from the functions in 2 places

 

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__.$this->getLangLink((int)($id_lang)).$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__.$this->getLangLink((int)($id_lang)).$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);
}

 

3rd file: ./classes/Tools.php

 

update the function generateHtaccess()

 

find inside the function

 if ($multilang)
 {
.....
....
   	 $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$2&isolang=$1&noredirect=1 [QSA,L]';
		$tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$2&isolang=$1 [QSA,L]';
....
....

 

Add the following lines:

//remove link id by Ha!*!*y
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-z]{2})/([a-zA-Z0-9-])(/[a-zA-Z0-9-]*)+ category.php?category_name_seo=$2&isolang=$1&noredirect=1 [QSA,L]';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-z]{2})/([a-zA-Z0-9-]*) category.php?category_name_seo=$2&isolang=$1&noredirect=1 [QSA,L]';
//remove link id by Ha!*!*y

 

Find

 // Notice : the id_category rule has to be after product rules.
 // If not, category with number in their name will result a bug
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$1&noredirect=1 [QSA,L]';
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$1 [QSA,L]';

 

Add the following lines:

//remove link id by Ha!*!*y
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*)(/[a-zA-Z0-9-]*) category.php?category_name_seo=$1&noredirect=1 [QSA,L]';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*) category.php?category_name_seo=$1 [QSA,L]';
//remove link id by Ha!*!*y

 

Add this at the end of file: ./config/config.inc.php

 //remove link id by Ha!*!*y
 if (Tools::getValue('product_name_seo'))
 {
  $id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
		SELECT `id_product`
		FROM `'._DB_PREFIX_.'product_lang`
		WHERE `link_rewrite` = \''.Tools::getValue('product_name_seo').'\'');
  $_GET['id_product'] = $id_product;
 }

Than Go to:

Back Office > Tools > Generators

 

Generate your ".htaccess" file by clicking the button

Edited by HA!*!*Y

Share this post


Link to post
Share on other sites

Brilliant, thanks for this. I will try this out as soon as I get the chance. I'm interested to see what bit of code I got wrong when trying it myself (probably the htaccess file - I must admit I don't quite understand all the rewrite code).

Share this post


Link to post
Share on other sites
ODM    5

if you find that there is an error with the category id

There is 1 error :

Missing category ID

 

you will have to do the fallowing

 

Change in /classes/Tools.php (just remove the "+" sign before the filename)

FROM

 

//remove link id by Ha!*!*y

$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';

$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';

$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*)(/[a-zA-Z0-9-]*)+ category.php?category_name_seo=$1&noredirect=1 [QSA,L]';

$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';

$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';

$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*)+ category.php?category_name_seo=$1 [QSA,L]';

//remove link id by Ha!*!*y

TO

 

 

//remove link id by Ha!*!*y

$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';

$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';

$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*)(/[a-zA-Z0-9-]*) category.php?category_name_seo=$1&noredirect=1 [QSA,L]';

$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';

$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';

$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*) category.php?category_name_seo=$1 [QSA,L]';

//remove link id by Ha!*!*y

 

Add at the end of /config/config.inc.php

 

if (Tools::getValue('category_name_seo'))

{

$id_category = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('

SELECT `id_category`

FROM `'._DB_PREFIX_.'category_lang`

WHERE `link_rewrite` = \''.Tools::getValue('category_name_seo').'\'');

$_GET['id_category'] = $id_category;

}

 

 

and regenerate you htaccess

Share this post


Link to post
Share on other sites

please I have 1.4.8.2 I tried to modify that file, but I do wrong some code, if I use file modified by me it doesn't work (500 error), please could you give to me file right for that version of ps?

Thanks

Share this post


Link to post
Share on other sites

Have you modified ALL the files necessary?

 

./controllers/ProductController.php

./controllers/CategoryController.php

./classes/Link.php

./classes/Tools.php

./config/config.inc.php

 

..AND generated a new htaccess file through your admin?

Share this post


Link to post
Share on other sites

[edit]

 

Works great on presta 1.4.5.1

 

Thanks for this solution!!! :D

Edited by matyz

Share this post


Link to post
Share on other sites

all work excelent , but sitemap isn't ok ... i have some like " /content/ name of category" ... webmaster found as broken link or page not found, but link working ... what happening ? use diferent sitemap generator ... result is same

Edited by corint1

Share this post


Link to post
Share on other sites

Hi, in 1.4.7, I did as above steps but there is an error when clicking on the product item.

There is 1 error :

  1. Product not found

What's wrong with that?

 

It works now! for my mistake~

 

Thank you for your hard work!

Edited by tranfy

Share this post


Link to post
Share on other sites

Hello, I am writing you because I had changed the URL of the items will be displayed without the category.

 

Ex. www.web.com/5-category/124-product.html to www.web.com/124-product.html

 

This I have taken from this post: http://www.prestashop.com/forums/topic/30419-remove-category-from-product-url/

 

When I apply the changes that you have indicated the URL shown without ID but instead the categories reappear in the URL.

 

I would like this: www.web.com/product.html

 

Someone could help me fix this?

 

Thanks!

Share this post


Link to post
Share on other sites

FREE module available now:

http://www.prestashop.com/forums/index.php?/topic/110922-friendly-urls-without-id-number/page__view__findpost__p__883380

 

Hello, I am writing you because I had changed the URL of the items will be displayed without the category.

 

Ex. www.web.com/5-category/124-product.html to www.web.com/124-product.html

 

This I have taken from this post: http://www.prestasho...om-product-url/

 

When I apply the changes that you have indicated the URL shown without ID but instead the categories reappear in the URL.

 

I would like this: www.web.com/product.html

 

Someone could help me fix this?

 

Thanks!

 

antonpas_bcn

if all you want to do is remove the category name from URL its really easy

 

go to file ./classes/Link.php and find public function getProductLink

and edit out the line from

 

if (isset($id_product->category) AND !empty($id_product->category) AND $id_product->category != 'home')
 $link .= $id_product->category.'/';

 

TO

if (isset($id_product->category) AND !empty($id_product->category) AND $id_product->category != 'home')
 $link .= '';

 

 

AND ALSO

$link .= (_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang));

if ($category AND $category != 'home')
 $link .= $category.'/';

 

TO

$link .= (_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang));

if ($category AND $category != 'home')
 $link .= '';

Edited by HA!*!*Y

Share this post


Link to post
Share on other sites

Thank you for this solution. I want to ask what kind of side effects can be occur by doing these changes. İnitially I think about:

 

1-Duplicate url - Canonical url problems

2-Speed and performance problems

3-Core function or module problem

 

What kind of undesirable effects can be come out when we do this changes? Or isn't there any problem or negative effects?

Share this post


Link to post
Share on other sites

Kerym there are some negative effects from it

1. Duplicate urls if you create two Products with the same seo url than prestashop will redirect you the the 1st of the 2 urls

 

2. if you keep the ID in the URL than you could change the SEO URL and the old URLS will 301 redirect to the new address

----- old url: www.web.com/category/124-product.html

----- new url: www.web.com/category/124-new-seo-url.html

 

3. As long as the modules use the getProductLink() function for the URLs there should not be any issues from it.

 

4. And far as performances go i don't see any slow down

Share this post


Link to post
Share on other sites

To remove number from Category URL

 

1st file: ./controllers/CategoryController.php

 

update the function preProcess()

public function preProcess()
{
	if ($id_category = (int)Tools::getValue('id_category'))
		{ $this->category = new Category($id_category, self::$cookie->id_lang); }
	else //remove link id by Ha!*!*y
	{
		$id_category = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
			SELECT `link_rewrite`
			FROM `'._DB_PREFIX_.'category_lang`
			WHERE `link_rewrite` = \''.Tools::getValue('category_name_seo').'\'');
		$this->category = new Category($id_category, self::$cookie->id_lang);
	} //remove link id by Ha!*!*y
....

 

2nd file: ./classes/Link.php

 

update the function getCategoryLink

I removed (int)($id_category->id).'-'. from the functions in 2 places

 

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__.$this->getLangLink((int)($id_lang)).$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__.$this->getLangLink((int)($id_lang)).$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);
}

 

3rd file: ./classes/Tools.php

 

update the function generateHtaccess()

 

find inside the function

 if ($multilang)
 {
.....
....
   	 $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$2&isolang=$1&noredirect=1 [QSA,L]';
		$tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$2&isolang=$1 [QSA,L]';
....
....

 

Add the following lines:

//remove link id by Ha!*!*y
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-z]{2})/([a-zA-Z0-9-])(/[a-zA-Z0-9-]*)+ category.php?category_name_seo=$2&isolang=$1&noredirect=1 [QSA,L]';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-z]{2})/([a-zA-Z0-9-]*) category.php?category_name_seo=$2&isolang=$1&noredirect=1 [QSA,L]';
//remove link id by Ha!*!*y

 

Find

 // Notice : the id_category rule has to be after product rules.
 // If not, category with number in their name will result a bug
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$1&noredirect=1 [QSA,L]';
 $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$1 [QSA,L]';

 

Add the following lines:

//remove link id by Ha!*!*y
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*)(/[a-zA-Z0-9-]*) category.php?category_name_seo=$1&noredirect=1 [QSA,L]';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
		$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*) category.php?category_name_seo=$1 [QSA,L]';
//remove link id by Ha!*!*y

 

Add this at the end of file: ./config/config.inc.php

 //remove link id by Ha!*!*y
 if (Tools::getValue('product_name_seo'))
 {
  $id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
		SELECT `id_product`
		FROM `'._DB_PREFIX_.'product_lang`
		WHERE `link_rewrite` = \''.Tools::getValue('product_name_seo').'\'');
  $_GET['id_product'] = $id_product;
 }

Than Go to:

Back Office > Tools > Generators

 

Generate your ".htaccess" file by clicking the button

 

Hi! HA!*!*Y

I am stuck with Your tutorial an I get only blank page :(

I have prestashop 1.4.8.2

 

Best Regards

Raitis

Share this post


Link to post
Share on other sites

Thank you for detailed answers HA!*!*Y you are great.

 

Prestashoponline what is the difference of your module? What kind of benefits does your module have more than HA!*!*Y's solution on deleting id from urls?

 

Thanks

Share this post


Link to post
Share on other sites

prestashoponline's module is for money ... this is the diference...

 

This module has also been reported for potentially being stolen content. Please do not purchase it until this has been resolved.

 

Thank you for detailed answers HA!*!*Y you are great.

 

Prestashoponline what is the difference of your module? What kind of benefits does your module have more than HA!*!*Y's solution on deleting id from urls?

 

Thanks

 

Please do not purchase this module. It has been reported as potential stolen content. We are investigating.

Share this post


Link to post
Share on other sites

I am moving to a new post for updates see URL:

 

http://www.prestasho...hout-id-number/

 

 

No more file editing i have a free module

 

did not fix the cms links as of now

 

plz note its a bata need to be tested

 

change log (removeURLid_v0.1b.2.zip)

- fixed name typo (capital class name) that caused problem with installing

 

change log (removeURLid_v0.1b.1.zip)

-fixed the CategoryController file path by corint1

-module now edits the config file

 

change log (removeURLid_v0.1b.1.zip)

- 1st release

removeURLid_v0.1b.zip

removeURLid_v0.1b.1.zip

removeURLid_v0.1b.2.zip

Edited by HA!*!*Y

Share this post


Link to post
Share on other sites

No more file editing i have a free module

 

did not fix the cms links as of now

 

plz note its a bata need to be tested

 

:( for me not working ....

 

 

There is 1 error :

  1. Product not found

Share this post


Link to post
Share on other sites

working perfect...but must modify lines :

 

'CategoryController' => _PS_ROOT_DIR_ . $slash . '/override/classes/Tools.php',

to

'CategoryController' => _PS_ROOT_DIR_ . $slash . '/override/classes/CategoryController.php',

 

in all 3 places ...

 

tks ...

 

read all specification or search in files for explication ....

//Edit the conf file??

//config.inc.php

isn't possible to append ? or create o new file and copy like other files ...

 

problem is with install ... if need cu override other procedures in this files , when installing this module lost all modification (copy new files, not append modifications)...same problem is on uninstall...backup not working ... append is a solution ... is possible ? same problem in on uninstall...

Edited by corint1

Share this post


Link to post
Share on other sites

isn't ok ...fopen and fclose isn't allowed by most hosting provider ... they recommend to use curl function ...

 

with install or uninstall problem is same lost any previously modification... tks

Share this post


Link to post
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

×