staticache icon indicating copy to clipboard operation
staticache copied to clipboard

.htaccess rules combining -f with [NC] causes warning and has no effect

Open ovenum opened this issue 1 year ago • 0 comments

Looking at the apache error logs, trying to fix an unrelated issue, i noticed lots of warning messages for the staticache .htaccess rules.

[rewrite:warn] RewriteCond: NoCase option for non-regex pattern '-f' is not supported and will be ignored.

These are caused by the .htaccess rules from the staticache documentation

RewriteCond %{DOCUMENT_ROOT}/site/cache/%{SERVER_NAME}/pages/%{REQUEST_URI}/index.html -f [NC]
RewriteRule ^(.*) %{DOCUMENT_ROOT}/site/cache/%{SERVER_NAME}/pages/%{REQUEST_URI}/index.html [END]

RewriteCond %{DOCUMENT_ROOT}/site/cache/%{SERVER_NAME}/pages/%{REQUEST_URI} -f [NC]
RewriteRule ^(.*) %{DOCUMENT_ROOT}/site/cache/%{SERVER_NAME}/pages/%{REQUEST_URI} [END]

Apparently combining -f with [NC] is not supported and, as the warning message says, will be ignored.

The [NC] could be dropped without causing any breaking changes. But it could be better to find a solution how get case insensitive matching for both rules.

Apache Version Server version: Apache/2.4.58 (Unix

ovenum avatar Dec 08 '23 10:12 ovenum