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]
精彩评论