I have this rule in .htaccess
# prevents files starting with dot to be viewed by browser
RewriteRule /\.|^\. - [F]
I need Forbidden all files with start dot, it's OK. But I need allow folder .well-known
How do you do this?
Thanks a lot.
You could simply add another rule first, with nothing but the [L]
flag, meaning "stop here if this rule matches":
# Match this path and do nothing
RewriteRule /\.well-known|^\.well-known - [L]
# prevents files starting with dot to be viewed by browser
RewriteRule /\.|^\. - [F]
Or you could qualify your existing rule with a RewriteCond:
RewriteCond %{REQUEST_URI} ! /\.well-known|^\.well-known
RewriteRule /\.|^\. - [F]
您可以使用负数前瞻来允许该特定文件夹:
RewriteRule (?:^|/)\.(?!well-known(?:/.*)?$) - [F,NC]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.