Jump to content

Media Server + Friendly URL = No Product images


Recommended Posts

Media Server + Friendly URL = No Product images

(Sorry for such a long post. I wanted to give as much information I had to help find a solution).

 

I have set up my CDN with the following folders:
img

modules

themes

(Everything is on the web. I have no local setup).

 

With my CDN listed in media server, and friendly URL on, themes and modules, (banner images and the like), and their images function properly, but no product images are served anywhere on my site.

(My CDN img folder uses the properly nested folders, and is a duplicate of my host files).

 

The product image URL with Media Server filled in and Friendly URL's on is: MYCDN.com/5468-large_default/celtic-cross.jpg   It will not display an image with these settings.

 

With Friendly URL off, my product images are properly displayed from my CDN.

The product image URL with Media Server filled in and Friendly URL's off is MYCDN.com/img/p/5/4/6/8/5468-large_default.jpg

 

With my CDN removed from media server, and Friendly URL on, images are properly displayed.

MYWEBSITE.com/5468-large_default/celtic-cross.jpg

 

With no media server and friendly URL's off the images are displayed properly:
MYWEBSITE.com//img/p/5/4/6/8/5468-large_default.jpg

 

 

My product images are displaying with every conceivable setting,

EXCEPT for the combination of: media server filled in AND Friendly URL checked.

I can see the pattern, I just don't know how to get my media server files to be seen with Friendly URL's enabled.

 

I have turned off Freindly URL's to trigger a new htaccess file.

No change.

Turned Friendly URL back on to trigger a new htaccess. file.
Does not display product images with Friendly URL checked and Media Server filled in.

 

I have deleted the htaccess file. No change.

 

I have Apache optimization turned off until I can figure this out.

 

Is there a re-direct I need to put in the htaccess file to get the images on my CDN to cooperate with Friendly URL's?

 

If you need anymore information. please ask!

 

I've gone from not knowing a damn thing about any of the media server and CDN stuff to where I am now all in the past few days solo. I have asked questions in these forums as well as in my hosting service forum. No one has helped me at all.
I have Googled my finger numb researching this and have found few if anything information regarding this.

 I find many questions asked by others, and far and few answers. So here I am.
 

Please take pity on me and shove me in the right direction.

 

Thanks!

 

 

 

Link to comment
Share on other sites

Maybe by adding the htaccess line that differs when friendly URL's is on and Media server is one might get an answer to this.

 

These are the lines referring to image when Friendly URL's are ON and Media Server is ON

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

# Images	
RewriteCond %{HTTP_HOST} ^MYCDN$ [OR]	
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$	
%{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]	

These are the lines when Friendly URL's are ON and Media Server is OFF:

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

# Images	
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$	
%{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]	

This line is the only difference.

RewriteCond %{HTTP_HOST} ^MYCDN$ [OR] 

Why is it using the re-direct OR, and is that causing the problem?
 

And before you ask, I know spit about code. When I was in school, computer hard drives took up entire rooms, and we used punch cards and flow charts !! LOL I'm just trying to supplement my income with a shop on the net.

 

Can anyone help me understand why, when I am using a media server AND Friendly URL's my images do not show on the front end?

Link to comment
Share on other sites

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

Put htaccess on meda server but change it to:



# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# http://www.prestashop.com - http://www.prestashop.com/forums

<IfModule mod_rewrite.c>

# Disable Multiviews
Options -Multiviews

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

# Images
RewriteCond %{HTTP_HOST} ^my-media-server.com$
RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1-$2$3$4.jpg [L]
RewriteCond %{HTTP_HOST} ^my-media-server.com$
RewriteRule ^([0-9]+)\-([0-9]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1-$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^my-media-server.com$
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^my-media-server.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} ^my-media-server.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} ^my-media-server.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} ^my-media-server.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} ^my-media-server.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} ^my-media-server.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} ^my-media-server.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} ^my-media-server.com$
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^my-media-server.com$
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]
# AlphaImageLoader for IE and fancybox
#RewriteCond %{HTTP_HOST} ^my-media-server.com$
#RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]

# Dispatcher
#RewriteCond %{REQUEST_FILENAME} -s [OR]
#RewriteCond %{REQUEST_FILENAME} -l [OR]
#RewriteCond %{REQUEST_FILENAME} -d
#RewriteCond %{HTTP_HOST} ^my-media-server.com$
#RewriteRule ^.*$ - [NC,L]
#RewriteCond %{HTTP_HOST} ^my-media-server.com$
#RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,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>

FileETag INode MTime Size
<IfModule mod_deflate.c>
	<IfModule mod_filter.c>
		AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/x-javascript
	</IfModule>
</IfModule>

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

# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again


that did it for me! Keep only images rewrite. 

Link to comment
Share on other sites

  • 7 months later...

This method worked for me.

Step 1: Enable friendly url . check everything is working fine without media server. Make sure friendly is enabled and media server is disabled

when step 1 is working you will see url of your products as http://ec2.aws.XXXXXXXXX.com/1-large_default/faded-short-sleeves-tshirt.jpg

Step 2 : enable media server now . i,m using cloudfront as cdn and s3 as bucket

when media server is enabled

you will come across 2 scenarios

1.css and js wont load and even images wont load

2.images will load but css and js wont load

fix for this is: goto Advanced parameters -> Preformance -> CCC(combine compress and cache)

Smart cache for CSS -- select no if it is yes.

    in my case it is rootofserver/etc/httpd

in your case it might be same or it might be

     rootofserver/etc/apahce/        or rootofserver/etc/apahce2/

step 2. once your inside the folder open httpd.conf file in any editor u like..

again in my case

        its httpd.conf  it might be same or it will be        apaceh2.conf or apache.conf

step 3. once you have opened the file in any of the text editor
find these below lines and Allowoverride set it to All if it is none.(make sure 'a' is Capital)

        DocumentRoot "/var/www/html"        #        # Each directory to which Apache has access can be configured with respect        # to which services and features are allowed and/or disabled in that        # directory (and its subdirectories).         #        # First, we configure the "default" to be a very restrictive set of         # features.          #        <Directory />            Options FollowSymLinks            AllowOverride All        </Directory>

next find these set of lines and set Allowoverride to All (make sure 'a' is Capital)

        <Directory "/var/www/html">        #        # Possible values for the Options directive are "None", "All",        # or any combination of:        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews        #        # Note that "MultiViews" must be named *explicitly* --- "Options All"        # doesn't give it to you.        #        # The Options directive is both complicated and important.  Please see        # http://httpd.apache.org/docs/2.2/mod/core.html#options        # for more information.        #            Options Indexes FollowSymLinks        #        # AllowOverride controls what directives may be placed in .htaccess files.        # It can be "All", "None", or any combination of the keywords:        #   Options FileInfo AuthConfig Limit        #            AllowOverride All       

Once you have finished editing this file.. upload it back to the server or if you can save it in the server itself do it. after uploading back to the server make sure to check this file again .if it has the edited changes. if not open putty or any command line tool your using and set

 chmod 0666 to the file 

the command is

"sudo chmod 0666 /etc/httpd/httpd.conf" 

copy paste and hit enter in command line interface.make sure the file name is as it is in your server. and also the route.

 

If even after all these changes your product images are still not loading then

 

Goto your cdn console and set the origin as your webserver itself. dont use s3 bucket.

ex if your site domain name (while development) may be

 ec2.userxxxxxxxx.aws.com (if amazon ec2) 

or any other service if your using provide that name as the origin for your cdn. as this will keep the files in sync between your server and the cdn where as the s3 bucket you have to manually update the master copy of your site.(there are methods to achieve sync between s3 and server but i have not tried it yet)

 

follow these steps and it might get your site working properly.. this worked out great for me and the site is now url friendly and media server enabled.

Edited by abhi.globalistic (see edit history)
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...