Mod重写允许访问txt文件

时间:2016-11-02 21:18:20

标签: php apache .htaccess mod-rewrite

我正在使用名为Batflat的波兰CMS,.htaccess不允许访问txt文件。我只需要访问 robots.txt 其他txt文件可能无法访问。

.htaccess内容:

# Prevent directory listings
Options -Indexes

# Prevent visitors from viewing files directly
<FilesMatch "\.(sdb|md|html|txt)$">
<IfModule mod_authz_core.c>
    Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
    Order deny,allow
    Deny from all
</IfModule>
</FilesMatch>

# URL rewrites
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(inc/|themes/|tmp/).*\.(php|html)$ - [F,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L]
</IfModule>

我不熟悉.htaccess - 你能帮我解决问题吗? 谢谢 SK

1 个答案:

答案 0 :(得分:0)

我收到的答案应该是5行:

<FilesMatch "(\.(sdb|md|html|txt)|(?<!robots.txt))$">

也许它会解决某个问题。 电贺 SK