Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GodziLaravel's avatar

htaccess

Hello How to prevent access to txt files except if this file is started by sitemap(.*).txt or by robots.txt

something like :

<FilesMatch "(?i)((\.tpl|.blade|\.ini|\.log|(?<!robots)\.txt))">
 Require all denied

but it accepts only robots.txt, and I want to add also txt files with prefix sitemap

thanks

0 likes
1 reply
D9705996's avatar

Would it not make more sense to have an allow rule for the things you want to allow?

<FilesMatch "sitemap.*\.txt">
    Require all granted
</FilesMatch>

Please or to participate in this conversation.