.htaccess redirect to /var/assets not working on Strato hosting


#1

Hi. I have set up an pimcore installation that is working fine so far locally on Mamp and also on an DDEV docker environment. But when i move it to Strato hosting (using with subdomain “pimcore.*.de” in a subdirectory of the hosting package) the redirect to /var/assets is not working? Maybe someone of you had a similar problem. I have no clue and also don’t wanna touch/change the .htaccess file. Regards


#3

I think assets will not load when $_SERVER[‘DOCUMENT_ROOT’] will not point to web folder of Pimcore. In case of Strato hosting (its a small hosting package) the document root points to “two parent folders above”. htaccess fails in this case. htaccess assets redirect in this case will not work.
The rest is working properly backend and frontend (except files redirected to /var/assets).


#4

You can just alter .htaccess a bit. Take a look here:
RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}/var/assets%{REQUEST_URI} -f
RewriteRule ^(.*)$ /var/assets%{REQUEST_URI} [PT,L]

You’ll need to add your install dir on line 2 & 3.


#5

thx for your feedback. adding install dir’s doesn’t help. what i have not recognized till now is that the rewriting for thumbnails work and for assets not? for me it looks the same :neutral_face: i have no clue :grimacing: very strange :exploding_head:
i think my initial observation is wrong.

# ASSETS: check if request method is GET (because of WebDAV) and if the requested file (asset) exists on the filesystem, if both match, deliver the asset directly
# FAILS?!
RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}/var/assets%{REQUEST_URI} -f
RewriteRule ^(.*)$ /var/assets%{REQUEST_URI} [PT,L]

# Thumbnails
# works?!
RewriteCond %{REQUEST_URI} .*/(image|video)-thumb__[\d]+__.*
RewriteCond %{DOCUMENT_ROOT}/var/tmp/%1-thumbnails%{REQUEST_URI} -f
RewriteRule ^(.*)$ /var/tmp/%1-thumbnails%{REQUEST_URI} [PT,L]

#6

Well, both do the same: they cancel the Apache 404’s, because if it not exists, there’s a rule later on which will catch the request. Are you sure the file exists on disk? + Can you erase the whole .htaccess (for testing) and try to request an asset?


#7

Yes. The images are available. As a workaround for the few places where i have used the original image in /var/assets i use now generated thumbnails in the fact that this redirect works :thinking:

What would be very interesting is why these redirects are needed… as an url shortener?
Why not user pragmatically the direct uri /var/assets/foo_folder/bar_image.jpg?

Regards