如何创建.htaccess查询,检查文件和cookie是否存在?

时间:2011-06-03 17:25:55

标签: .htaccess

我正在尝试创建一个HTACCESS重定向,用于检查文件和cookie是否存在。它需要检查以下内容......

If a cookie called "my-cookie" does NOT exists
AND a file in the "/cached/" folder exists with the same name as the REQUEST_FILENAME
THEN load the file from the "cached" folder. 

也可以用“。”替换“/”。在REQUEST_FILENAME中。

1 个答案:

答案 0 :(得分:1)

根据这一点,应该让你在路上:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_COOKIE} !^.*cookie-name.*$ [NC]
RewriteCond cached/%{REQUEST_FILENAME} -f
RewriteRule (.*) cached/%{REQUEST_FILENAME}/ [L]