Issue with .htaccess cookies

I need to block access to the folder of my Wordpress site when certain cookie value is not set. The code below added to .htaccess is not working on live website. Please help me to solve this issue

RewriteEngine On

RewriteCond %{THE_REQUEST} /wp-content/uploads/microsite-files/ [NC]
RewriteCond %{HTTP_COOKIE} !cookie_microsite=confirmMicroSite [NC]
RewriteRule ^ /news/ [L,R]

That’s a rewrite rule, but the syntax here would be the same for a WAF rule as well as a Redirect, which is what your .htaccess is doing:

(http.request.uri.path contains "wp-content/uploads/microsite-files" and not http.cookie contains "cookie_microsite=confirmMicroSite")

1 Like