开发者

How do i create a .htaccess query which will check if a file and a cookie exists?

I am trying to cre开发者_开发知识库ate a HTACCESS redirect which checks if a file and cookie exists. It needs to check the following...

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. 

Also it possible it would be nice to replace "/" with "." in the REQUEST_FILENAME.


Something along the lines of this should get you on the way:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜