我的.htaccess文件:htaccess的被拒绝访问的index.php作为目录索引
DirectoryIndex index.php
order allow,deny
<FilesMatch "^(index|testfile)\.php$">
Allow From All
</FilesMatch>
拒绝访问的网站的根,这通常会打开index.php文件。加载网站的唯一方法是去mysite.com/index.php
而不是mysite.com
如果我删除order
它按预期工作,但现在该目录中的任何文件都可以访问。
如何配置htaccess拒绝除index.php
之外的所有文件,但也允许导航到mysite.com
而不是mysite.com/index.php
?使用mod_rewrite
DirectoryIndex index.php
order Deny,Allow
# deny everything except landing page
<FilesMatch ".">
Deny From All
</FilesMatch>
# allow index.php and testfile.php
<FilesMatch "^(index|testfile)\.php$">
Allow From All
</FilesMatch>
替代的解决方案:
的downvoters可以解释为什么? –