如果缓存文件夹中不存在文件,则htaccess重写

编程入门 行业动态 更新时间:2024-10-06 17:13:55
本文介绍了如果缓存文件夹中不存在文件,则htaccess重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想检查缓存文件夹中是否不存在文件,然后将其重新连接到php文件.

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/images/logo.jpg,可从example/cache/images/logo.jpg检查 eg2:example/images/user/user1.jpg从example/cache/user/user1.jpg进行检查 eg3:example/css/style.css来检查example/cache/css/style.css

eg1 : example/images/logo.jpg to check from example/cache/images/logo.jpg eg2 : example/images/user/user1.jpg to check from example/cache/user/user1.jpg eg3 : example/css/style.css to check from example/cache/css/style.css

请帮助我.

谢谢.

我的htaccess代码:

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:

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]

更多推荐

如果缓存文件夹中不存在文件,则htaccess重写

本文发布于:2023-11-02 06:57:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551680.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   不存在   重写   缓存   夹中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!