HddnTHA
HddnTHA

Reputation: 1059

Prestashop Rewrite Rule Renders Wrong Image Path

We are currently using prestashop 1.5.6.2 and imported a huge xml file (14k row) into mysql via 3rd party php functions. Everything fine till product page in prestashop. But in product page prestashop calling image like

<img src="http://www.domain.com/img/p/1/1/3/113-large_default.jpg" title="Product Name" alt="Product Name" id="bigpic" width="264" height="264">

We expect

<img src="http://www.domain.com/img/p/113/113-large_default.jpg" title="Product Name" alt="Product Name" id="bigpic" width="264" height="264">

Unfortuanetly; Prestashop adding slashes between first product id like;

/1/1/3/113-large_default.jpg 

I'm not sure but it's some kind of .htaccess rewriterule problem. Our .htaccess looks like;

<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>

# Disable Multiviews
Options -Multiviews

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain.com.tr$
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

# AlphaImageLoader for IE and fancybox
RewriteCond %{HTTP_HOST} ^www.domain.com.tr$
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]
RewriteCond %{HTTP_HOST} ^www.domain.com.trm$
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

# AlphaImageLoader for IE and fancybox
RewriteCond %{HTTP_HOST} ^www.domain.com.trm$
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]
</IfModule>

#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404

Does anyone can help if they have had some kind of issue?

Upvotes: 1

Views: 3315

Answers (2)

Douglas
Douglas

Reputation: 1258

Copied from Jon Lin's answer here

The extra slash in the URL changes the relative URL base. All your links that are relative URLs in your content will now use the incorrect base. You can fix this by either using absolute URL's (starts with a /) or add a base in your page's header:

<base href="/" />

Upvotes: 0

yenshirak
yenshirak

Reputation: 3106

There is no rewrite problem, the image path is correct.

If you want to use your custom image path then in product.tpl change the image tag with the following:

<img src="img/p/{$product->id}/{$product->id}-large_default.jpg">

Upvotes: 1

Related Questions