What does this mean:
RewriteRule "(^|/)\." - [F]
I know the F flag means to throw a 403 forbidden error. And I know the escaped period means that directories starting with a period are forbidden. But what is the meaning of the caret, pipe and slash within the parenthesis? What would be the difference between the statement above and this one:
RewriteRule "\." - [F]
What if I wanted to flag URLs as forbidden when they start with a period but with an exception for this directory:
.well-known
Update: It looks like I can satisfy the latter requirement with...
RewriteRule "(^|/)\.(?!well-known)" - [F]
I'm still wondering what is the meaning of the caret, pipe and slash within the parenthesis.
^
and$
are special characters that represent the beginning and end of strings (or lines)the
|
is anOR
symbol(^|/)\.
expands to^.
or/.
(without escaping slash for clarity)^.
= any string that has a.
as the first character/.
= any string with a/.