I’m using a cache busting engine for my CSS and JS scripts based on PHP and .htaccess. So in PHP i built the following function:
function CreateFileFingerprint($RelativePath)
{
$PathInfo = pathinfo($RelativePath);
return $PathInfo['dirname'].'/'.$PathInfo['filename'].'.'.filemtime(DATA_BASEPATH.$RelativePath).'.'.$PathInfo['extension'];
}
While in my .htaccess I use expiration headers:
FileETag None
Header Unset ETag
ExpiresActive On
ExpiresDefault A2592000
ExpiresByType application/javascript A31536000
ExpiresByType text/css A31536000
ExpiresByType text/javascript A31536000
<FilesMatch "[^\.php]$">
Header Append Cache-Control "public"
</FilesMatch>
And a little mod_rewrite rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.(\d+)\.(css|js)$ $1.$3 [L]
Then in my PHP page I use the following code:
echo '<link rel="stylesheet" href="'.self::CreateFileFingerprint('/styles/style-base.css').'" media="all"/>';
Everything works fine, but now I would like to implement an universal PHP ErrorDocument for my site like explained here. The problem is that I need to merge my previous mod_rewrite rule with the one suggested in the link:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /errors/error.php [L]
Can someone help me please?
Many thanks!
remove negation from the conditions and tell it to not to try and match the rewriterules if its a file or directory. Think that should work