I'm trying to configure apache to serve static files for URLs like site.com/img/bla.jpg
.
Python cartridge + flask.
I know what there is an preconfigured alias for wsg/static
directory, so we can use site.com/static/bla.jpg
. But I need additional static directory.
Project structure:
/wsgi
.htaccess
/img -> $OPENSHIFT_DATA_DIR/some/path (soft link)
/static
application
In the backend I binded mysite.com/img/<filename>
for testing if apache or backend handles files - it returns "ok [filename]" string.
I have tried the following configs in htaccess:
1: site.com/img/1.jpg
-> "ok 1.jpg"
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f # with and without this condition
RewriteRule ^img/(.+)$ /static/$1 [L]
# RewriteRule ^img/(.+)$ /img/$1 [L]
# RewriteRule ^/img/(.+)$ /img/$1 [L]
# RewriteRule ^img/(.+)$ https://ssl.gstatic.com/gb/images/i1_3d265689.png [L]
As I understand regex doesn't match request URL and apache just passes stuff to backend?
2: site.com/img/1.jpg
-> "ok 1.jpg"
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /img/1.jpg https://ssl.gstatic.com/gb/images/i1_3d265689.png [L]
3: site.com/img/1.jpg
-> opens google's i1_3d265689.png
RewriteEngine On
RewriteBase /
RewriteRule /img/1.jpg https://ssl.gstatic.com/gb/images/i1_3d265689.png [L]
Note: no RewriteCond.
So how to make it work?
Again I want apache to serve mysite.com/img/<filename>
as wsg/img/<filename>
.
Is something wrong with openshift or I miss something?