Jump to content

Image path doesn't get served correctly after using media server


Recommended Posts

Hello

 

I am trying to use Media Server (CDN) for my prestashop configuration and as soon as i configure it, all links to my image is broken.

 

This is my CDN

http://blitz.example.com.s3-ap-southeast-1.amazonaws.com/img/p/3/0/5/1/3051-product_list_default.jpg

While prestashop prints this link:

http://blitz.xx.xx.s3-ap-southeast-1.amazonaws.com/3051-product_list_default/stannum-canvas-black-bs.jpg

The code that responsible for that is:

{$link->getImageLink($product.link_rewrite, $product.id_image, 'product_list_default')}

I am still trying to figure it out how can prestashop prints the correct url

 

By the way, this is an excerpt from my .htaccess that responsible for redirection

RewriteCond %{HTTP_HOST} ^blitz.xx.xx.s3-ap-southeast-1.amazonaws.com$ [OR]
RewriteCond %{HTTP_HOST} ^subdomain.xx.xx$
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]

Note: It is just a partial code from my .htaccess, i think it should be enough since the rest of the image redirection part a similar (apart from the variables that counts up until $10).

 

Can anyone please help me with this ?

 

 

Cheers,

 

Rama

Link to comment
Share on other sites

@Bellini, I add this blitz.xx.xx.s3-ap-southeast-1.amazonaws.com value on the Media Server.

 

I am using Prestashop 1.5.4.x by the way.

 

I think i can narrow down the problem. Somehow i gotta a hunch that i should create another .htaccess on my CDN's root, however i am not sure what to put.

 

I have tried to use the following .htaccess and put it on my CDN's root folder

 

<IfModule mod_rewrite.c>
RewriteEngine on


# Images
RewriteCond %{HTTP_HOST} ^blitz.xx.xx.s3-ap-southeast-1.amazonaws.com$
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^blitz.xx.xx.s3-ap-southeast-1.amazonaws.com$
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L]
RewriteCond %{HTTP_HOST} ^blitz.xx.xx.s3-ap-southeast-1.amazonaws.com$
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L]
RewriteCond %{HTTP_HOST} ^blitz.xx.xx.s3-ap-southeast-1.amazonaws.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L]
RewriteCond %{HTTP_HOST} ^blitz.xx.xx.s3-ap-southeast-1.amazonaws.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L]
RewriteCond %{HTTP_HOST} ^blitz.xx.xx.s3-ap-southeast-1.amazonaws.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L]
RewriteCond %{HTTP_HOST} ^blitz.xx.xx.s3-ap-southeast-1.amazonaws.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteCond %{HTTP_HOST} ^blitz.xx.xx.s3-ap-southeast-1.amazonaws.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L]
RewriteCond %{HTTP_HOST} ^blitz.xx.xx.s3-ap-southeast-1.amazonaws.com$
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^blitz.xx.xx.s3-ap-southeast-1.amazonaws.com$
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]


</IfModule>


<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 year"
</IfModule>

The problem is, CDN is not a webserver hence mod_rewrite most likely will fail.

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

  • 4 weeks later...

Same Problem here:

 

- i create a CDN Zone ,

- copied /img /themes /modules to the CDN

- put in backend the media server address

- clear cache and compile on ftp

- regenerate htacess

- try with friendly URL on and off 

 

Images : 404 > wrong redirect path, the same as above:  /p/3/1/3 instead of /313-product-...

Also if i activate smartcache for JS and CSS, the Cached file in CDNpath/themes/theme/cache ending in a 404 error, my site is completing broken

 

So how can i use the CDN and media server? is there a solution for this? or i forget something?

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