A
A
Alex2017-03-27 18:30:46
Apache HTTP Server
Alex, 2017-03-27 18:30:46

Why don't .htaccess rules apply to static files?

Site on WordPress. I'm doing a test using the redbot.org service .
At the root, the .htaccessline is written

Header set Cache-Control "max-age=31536000, public"

For the page itself - Title is set.
https://example.com/single-post
But for the uploaded file - There is no header.
https://example.com/wp-content/uploads/2017/04/image.jpg

Farther. All pictures are in two copies with a different type
https://example.com/wp-content/uploads/2017/04/image.jpg
https://example.com/wp-content/uploads/2017/04/image.webp

At the root, in .htaccessindicated
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_ACCEPT} image/webp
  RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
  RewriteRule ^(wp-content/uploads.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>

When checking
https://example.com/wp-content/uploads/2017/04/image.webp

I get Content-Type: image/webp
AND Cache-Control: max-age=31536000, public
But when requesting original image
https://example.com/wp-content/uploads/2017/04/image.jpg

I get Content-Type: image/jpeg and Cache-Control is not set
What's wrong?!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasya Petrov, 2017-03-27
@Kozack

A possible option - your static is processed by nginx-catfish and it doesn't reach Apache.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question