What is the syntax to append a string to the http request using <IfFile> in httpd.conf?

Viewed 12

<filename>.avif exists (in the document_root of an Apache 2.4 virtualhost).

I'm requesting the file without specifying the extention .avif:

https://<myServer>/<filename>

The HTTP_ACCEPT header contains image/avif

Now:

If the HTTP_ACCEPT contains image/avif then
    If the file with an appended .avif extension exists (<filename>.avif) then
        Rewrite request to serve <filename>.avif

RewriteEngine On
<If "%{HTTP_ACCEPT} =~ /image\x{2F}avif/">
    <IfFile %{REQUEST_URI} . '.avif'>
        RewriteRule ^(.+)$ $1.avif [L]
    </IfFile>
</If>  

Problem: <IfFile> doesn't find the file. I also tried {REQUEST_FILENAME} instead of {REQUEST_URI}.

What would be the correct syntax to query for the requested file with an appended .avif extension?

0 Answers
Related