sibrodo Posted April 27, 2015 Share Posted April 27, 2015 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 More sharing options...
bellini13 Posted April 27, 2015 Share Posted April 27, 2015 what did you add to the media server entries in the back office performance page? Link to comment Share on other sites More sharing options...
sibrodo Posted April 27, 2015 Author Share Posted April 27, 2015 (edited) @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 April 27, 2015 by sibrodo (see edit history) Link to comment Share on other sites More sharing options...
sibrodo Posted April 27, 2015 Author Share Posted April 27, 2015 I think it is also worth mentioning that the folder structure of my CDN is identical to the structure of Prestashop Root | | | |--- img | | | |------ p | |------ a (and so on..) | Link to comment Share on other sites More sharing options...
bellini13 Posted April 27, 2015 Share Posted April 27, 2015 If this is your CDN.... http://blitz.example.com.s3-ap-southeast-1.amazonaws.com/img/p/3/0/5/1/3051-product_list_default.jpg Then why are you using this as the media server value? blitz.xx.xx.s3-ap-southeast-1.amazonaws.com Link to comment Share on other sites More sharing options...
sibrodo Posted April 27, 2015 Author Share Posted April 27, 2015 @bellini, it is actually the same thing i masked a few chars for debugging purposes. http://blitz.example.com.s3-ap-southeast-1.amazonaws.com and blitz.xx.xx.s3-ap-southeast-1.amazonaws.com are actually referring t the same thing. It's just me not being consistent, since the first post i put example.com while on the other one i put xx.xx Link to comment Share on other sites More sharing options...
bellini13 Posted April 28, 2015 Share Posted April 28, 2015 you have friendly url turned on? Link to comment Share on other sites More sharing options...
m3442a Posted May 21, 2015 Share Posted May 21, 2015 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 More sharing options...
m3442a Posted May 21, 2015 Share Posted May 21, 2015 Update: the redirect path for the images working now : https://domaincdn-15dc.kxcdn.com/416-home_default/product.jpg but images dont show: Failed to load resource: the server responded with a status of 404 (Not Found) ?????? CCC for JS and CSS dont work Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now