wordpress - in .htaccess, how to detect a part of a cookie name with Regex? -


i'm setting .htaccess file prevent access within folder unless cookie set. issue cookie name can vary id number attached end of it, , have no control on that.

the cookie have setup can (frm_form30, frm_form31, etc.).

here's .htaccess code have far:

rewriteengine on rewritebase / rewritecond %{http_cookie} !^.*\bfrm_form(?:\d*\.)?\d+*.*$ [nc] rewriterule .* / [nc,l] 

i'm using this:

\bfrm_form(?:\d*\.)?\d+ 

as regex detect cookie starting frm_form , ending 2 digit number. can point me in right direction or tell me if i'm doing wrong?

the code works if use full cookie name (ex. frm_form30), rest of file --i think-- alright.

your appreciated!

to detect 2 digit number use \bfrm_form\d\d or \bfrm_form\d{2}.

your regex matches number, decimal part or not.

simplify expression , send forbidden header instead of redirecting :

rewriteengine on rewritebase / rewritecond %{http_cookie} !\bfrm_form\d\d\b [nc] rewriterule .* [f] 

Comments