I want to check if file is not exist in the cache folder, than rewire it to a php file.
RewriteCond %{DOCUMENT_ROOT}/cache/$0 !-f [NC]
RewriteRule ^([^.]+\.(jpg|png|gif|css|js))$ include/cache/optimizer.php?file=$1&type=$2&c=$0 [L,QSA,NC]
eg1 : example.com/images/logo.jpg to check from example.com/cache/images/logo.jpg
eg2 : example.com/images/user/user1.jpg to check from example.com/cache/user/user1.jpg
eg3 : example.com/css/style.css to check from example.com/cache/css/style.css
Please help me in it.
thank you.
My htaccess code:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# Admin area
RewriteRule ^admin(.*) admin$1 [L]
# Rule for compression images and scripts
RewriteCond %{DOCUMENT_ROOT}/cache%{REQUEST_URI} !-f [NC]
RewriteRule ^([^.]+\.(jpg|png|gif|css|js))$ include/cache/optimizer.php?file=$1&type=$2&c=$0 [L,QSA,NC]
# Check if file *.* exist in the cache foldel
RewriteCond %{DOCUMENT_ROOT}/cache/$0 -f [NC]
RewriteRule ^(.+?)/?$ /cache/$0 [L]
# Check if file index.html exist in the cache foldel
RewriteCond %{DOCUMENT_ROOT}/cache/$0/index.html -f [NC]
RewriteRule ^(.+?)/?$ /cache/$0/index.html [L]
# Normal behave
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
You need to remove negative check
!
and make it positive: