Jump to content

[SOLVED] CMS Pages Friendly URL breaking links


Arkadia

Recommended Posts

Hi guys,

 

I'm having a problem with my CMS pages (pages created via tools>CMS>add a new page). I am trying to use friendly urls and it's breaking the links to template images because it adds the word "content" to the URL so it's unable to find the images defined in my css files and my menu module.

 

The images are breaking because they are linking to:
content
/themes/zelco/img/zelimg/cart_button.jpg

instead of:

themes
/zelco/img/zelimg/cart_button.jpg

 

 

Pages not created via the CMS work fine.

 

This is more or less what the pages should look like: http://dev.zelco.com/1-home

 

BUT

 

The CMS pages are looking like this: http://dev.zelco.com/content/7-press

 

When I don't use friendly urls then the template works perfectly. But the client would prefer friendly urls. I've looked at the htaccess file but I'm not exactly sure how to change it so that it is able to find the correct directory for the applicable template files. These are the rules (in the htaccess file) that I believe are creating the url with "content" in it.

 

 

RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms=$1 [QSA,L]

RewriteRule ^content/category/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms_category=$1 [QSA,L]

 

Appreciate any help! :rolleyes:

Edited by Arkadia (see edit history)
Link to comment
Share on other sites

I'm still not winning with this ^ issue. When I view the page source, it shows the correct url, it seems the url is being rewritten by the htaccess file when friendly-urls are applied in the generator section of the prestashop backend. Switching off friendly urls fixes the issue, but I'd prefer to have them on. Anyone out there? :)

 

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Well it doesn't look like anyone reads these forums lol. But I resolved the issue...as simple as relative links missing a forward slash

 

Hi, I'm having almost this exact same problem and also the problem with either no replies on the forum or very few. Please can you give me a bit more detail on how you fixed this issue? I thought it was related to Javascript? Can .htaccess make links appear different on hover to how they are in the source?

 

It's ok - looks like I figured it out from what you said. Many Thanks for posting back that you had an answer. Shame the forum seems so empty of community spirit sometimes :-(

 

You saved the day for me :-)

Link to comment
Share on other sites

  • 1 month later...

I share the solution found as i good rimember on this forum.

 

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.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

This works for me... I also only have one language active. {$link->getCMSLink(7, 'return-guarantee')}

 

Whole example:

 

<li><a href="{$link->getCMSLink(7, 'return-guarantee')}">{l s='Return Guarantee' mod='tmfooterlinks'}</a></li>

  • Like 1
Link to comment
Share on other sites

  • 3 years later...

"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."

 

I am new to Prestashop, could you please mention the code here that how to write in .htaccess , also i couldn't find getCMSLink() function in classes/Link.php

 

My Prestashop version is 1.6.1.3

Edited by mesotek (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Hey guys, how did you get it done?
 
I'm trying to remove the content/ from all cms pages and leave the .html at the end. So for example to have /delivery.html
 
In Route to CMS page I have tried {rewrite}.html but it goes to a 404 page
I have tried just {rewrite} and it works! Also with {rewrite}.php works. 
Why is it not working with .html ?
 
I have also tried to use a htaccess rewriterule. So I left it as {rewrite} , which it works, and in my htaccess I have:
RewriteEngine On
RewriteRule ^delivery\.html /delivery [L,QSA,NC,P]

 

Still getting the 404 page.

 

 

Funny thing is if I remove the ssl from all pages the htaccess rewrite rule works! But I do need https on all pages really.

 

So strange. If anyone has a solution please post here.

 

thanks

Link to comment
Share on other sites

It's probably because .html is used for the product URLs. That's why PrestaShop uses /content/ to distinguish the CMS URLs from the product URLs. You can try temporarily changing the product URL to use something other than .html to see if that's the problem.

Link to comment
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
×
×
  • Create New...