Forum Moderators: phranque
Here's my instructions.... "If a user goes to this page, and they do NOT have this cookie set, and this file DOES exist, then give them this file (the one that does exist) without redirecting them.
Here's my (not working) .htaccess snippet:
# yes, original-dir/ONE Char/Many Chars/
RewriteCond %{HTTP_COOKIE} !^.*COOKIENAME.*$ [NC]
RewriteCond %{REQUEST_URI} ^/?original-request-dir/([^/])/(.*)/?$
# don't know if this actually works but need to save those vars - haven't gotten to this part of the problem yet.
RewriteCond -s cache/file/($1)/($2)/index.html
RewriteRule .* cache/file/$1/$2/index.html [L]
I have tried a full path to the file in the third line, I have tried using no variables and using paths I know exist, I have tried cutting back on the number of RewriteConds -- but each time I have more than one RewriteCond it fails with
File does not exist: %{DOCUMENT_ROOT}/original-dir
Thanks in Advance!
You can move the REQUEST_URI pattern to the RewriteRule for much faster execution (remove the leading slash, though). RewriteConds are not processed at all unless the RewriteRule pattern matches. Back-references to the URL-path-parts will also need to be updated to use $1/$2 instead of %1/%2.
Jim
So this should work?
RewriteCond %{HTTP_COOKIE} !cookiename
RewriteCond cache/file/11/index.html -s
RewriteRule ^/?request-directory/(.*)$ cache/file/$1/index.html [L]
If possible, try to avoid 'stacked' rewrites or redirects, and use the [L] flag on all rules, unless you can't re-code to avoid it.
And also, inspect the current 'chain' of steps and see if you can find where that double-slash is being injected... That's nasty, whether you use [PT] or not...
Jim