Jump to content

[SOLVED] Friendly URL: how to remove /content/ from URL


Recommended Posts

That directory is required so that PrestaShop can distinguish between CMS pages and categories. If you removed it, PrestaShop wouldn't know whether to search for a CMS page with the provided ID or a category with the provided ID.

Link to comment
Share on other sites

Thank you rocky for your quick reply. I understand the situation.

Do you think we might change /content/ into something else, for instance /services/, /products/ or in any case /one-of-my-keywords/, so that the extra level /---/ could be exploited for SEO purposes, instead of being only 'extra weight' on the URL?

Link to comment
Share on other sites

  • 1 year later...

Hi Rocky,

 

I'm having an issue with friendly urls and my post isn't getting responses. You seem like a friendly url rockstar. lol. Please take a look at my post? Would appreciate your assistance very much!

 

http://www.prestashop.com/forums/topic/143069-cms-pages-friendly-url-breaking-links/page__p__687561?do=findComment&comment=687561

 

Apologies if I'm breaking forum rules posting here?

Link to comment
Share on other sites

  • 3 months later...
  • 7 months later...

Hi @rocky, I have question about your post:

Yes, you can do that. You'll need to change "content" in "^content/" in the .htaccess file to another word and then change "content/" in the getCMSLink() function in classes/Link.php to match.

 

because i`d like to remove 'content' from url but no change so is possible? I try remove 'content' from file /classes/Link.php:

 

public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = NULL)
{
 $base = (($ssl AND Configuration::get('PS_SSL_ENABLED')) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true));

 if (is_object($cms))
 {
  return ($this->allow == 1) ?
($base.__PS_BASE_URI__.$this->getLangLink((int)($id_lang)).'[b]content[/b]/'.(int)($cms->id).'-'.$cms->link_rewrite) :
($base.__PS_BASE_URI__.'cms.php?id_cms='.(int)($cms->id));
 }

 if ($alias)
  return ($this->allow == 1) ? ($base.__PS_BASE_URI__.$this->getLangLink((int)($id_lang)).'[b]content[/b]/'.(int)($cms).'-'.$alias) :
  ($base.__PS_BASE_URI__.'cms.php?id_cms='.(int)($cms));
 return $base.__PS_BASE_URI__.'cms.php?id_cms='.(int)($cms);
}

 

on

 

public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = NULL)
{
 $base = (($ssl AND Configuration::get('PS_SSL_ENABLED')) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true));

 if (is_object($cms))
 {
  return ($this->allow == 1) ?
($base.__PS_BASE_URI__.$this->getLangLink((int)($id_lang)).'/'.(int)($cms->id).'-'.$cms->link_rewrite) :
($base.__PS_BASE_URI__.'cms.php?id_cms='.(int)($cms->id));
 }

 if ($alias)
  return ($this->allow == 1) ? ($base.__PS_BASE_URI__.$this->getLangLink((int)($id_lang)).'/'.(int)($cms).'-'.$alias) :
  ($base.__PS_BASE_URI__.'cms.php?id_cms='.(int)($cms));
 return $base.__PS_BASE_URI__.'cms.php?id_cms='.(int)($cms);
}

 

but isn`t good solution for my problem, do you have any idea?

Link to comment
Share on other sites

  • 7 months later...

Hi Rocky,

 

I applied your solution and it is giving me the error like:

  1. Missing category ID.

One more thing, I have also edited the Link.php file before to remove the ids from the url for SEO purpose so is it due to this?

 

and if yes then is there solution for this?

 

Thanks and waiting for your answer....

Link to comment
Share on other sites

×
×
  • Create New...