仅使用根htaccess文件拒绝和允许访问文件目录

时间:2020-05-08 21:03:01

标签: apache .htaccess

我有一个看起来像这样的目录:

enter image description here

我希望仅使用一个.htaccess来完成此操作,因为我的文件系统还不那么复杂。

.htaccess的内容

<FilesMatch "^\.">
  Order allow,deny
  Deny from all
</FilesMatch>

<Files ~ "^.*">
  Deny from all
</Files>

<Files ~ "^index\.php|css|js|.*\.png|.*\.jpg">
  Allow from all
</Files>

# Disable directory browsing
Options -Indexes

ErrorDocument 401 /webApp/Error/error.html
ErrorDocument 403 /webApp/Error/error.html
ErrorDocument 404 /webApp/Error/error.html

我试图阻止webApp文件夹中的任何内容,因为该文件夹包含了网页所需的所有内容。

我是htaccess的新手,我从阅读的内容中摘录了上面的代码,这显然是错误的,因为加载网页后,它就被拒绝了。

流的摘要,首先在根目录上打开站点index.php,在其中只是一些服务器日志内容,然后将其传递到home.php,在该php中设置一些变量并将其加载到首页。 html(然后链接css和js文件)

请注意,索引和家庭php将使用供应商,但我不认为.htaccess如果访问的是与运行服务器的同一访问(如果有人可以澄清的话,那将是很好的),则将不起作用。 >

我在做什么错了?

0 个答案:

没有答案
相关问题