M
M
Max2019-01-20 20:26:05
css
Max, 2019-01-20 20:26:05

Apache Image mapping via AliasMatch by HTTP_USER_AGENT condition - how?

Good afternoon!
The domain config has a condition for redirecting image requests to the HDD archive with them (works ok).

AliasMatch "^/wp-content/uploads/2019/../(..)(.*)$" "/mnt/hdd/dbimg/$1/$1$2"
    AliasMatch "^/wp-content/uploads/2018/../(..)(.*)$" "/mnt/hdd/dbimg/$1/$1$2"
    <Directory "/mnt/hdd/dbimg">
        Require all granted
    </Directory>

It is necessary to make the redirection not just, but according to the additional condition of the presence of HTTP_REFERER for example. That is, you need to apply the .htaccess rules, but it turns out that the Apache config works out earlier than .htaccess and already gives the image, but the .htaccess rules do not work.
.htaccess rule, for example:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} \.(jpg|jpeg|png|gif)$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?(mysite.com)  [NC]
RewriteRule (.*) watermark.php?src=$1 [L]
</IfModule>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2016-05-15
@lasmaster

You here: https://habrahabr.ru/post/126207/
Your figure is a parallelogram.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question