我想检查缓存文件夹中是否不存在文件,然后将其重新连接到 php 文件。
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 从 example.com/cache/images/logo.jpg 检查
eg2 : example.com/images/user/user1.jpg 从 example.com/cache/user/user1.jpg 检查
eg3 : example.com/css/style.css 从 example.com/cache/css/style.css 检查
请帮助我。
谢谢。
我的 htaccess 代码:
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]
您需要删除负面支票!
并使其积极:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# Admin area
RewriteRule ^admin(.*) admin$1 [L]
# Check if file index.html exist in the cache foldel
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/cache/$1/index.html -f [NC]
RewriteRule ^(.+?)/?$ /cache/$1/index.html [L]
# Check if file *.* exist in the cache foldel
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/cache/$1 -f [NC]
RewriteRule ^(.+?)/?$ /cache/$1 [L]
RewriteRule ^([^.]+\.(jpg|png|gif|css|js))$ include/cache/optimizer.php?file=$1&type=$2&c=$0 [L,QSA,NC]
# Normal behave
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)