Loading... Discuz!X3系列的一些目录是可以屏蔽PHP访问的,比如说`data、uc_client、uc_server/data/、static`等。 下文Discuz!X3简称DZX3 Discuz!X3屏蔽部分目录PHP访问权限的Nginx规则: DZX3的UCenter比较特殊一点,至少不能屏蔽`avatar.php`文件,因为DZX3动态调用头像是访问`uc_server/avatar.php`实现的。当然你也可以不排除`index.php和admin.php`的屏蔽访问。下面规则是**不屏蔽**访问uc_server目录下的`index.php、avatar.php、admin.php`的规则: ``` location ~ ^/data/.*.php$ {deny all;} location ~ ^/uc_client/.*\.php$ {deny all;} location ~ ^/uc_server/((?!index.php|avatar.php|admin.php).)*\.php$ {deny all;} location ~ ^/static/.*\.php$ {deny all;} location ~ ^/template/.*\.php$ {deny all;} ``` `source/plugin/`这个目录可能比较麻烦点,有些支付插件支付回调是访问这个目录下的文件来实现的。 参考规则,需要根据自己需求做修改,也可以联系本人付费定制: ``` location ~ ^/source/((?!plugin/插件目录1|plugin/插件目录2).)*\.php$ {deny all;} ``` 如果你没有这样的插件,那直接这样也不是不行: ``` location ~ ^/source/.*.php$ {deny all;} ``` DZX3的一些目录可以设置成555权限,来增强安全性。 比如说`api、archiver、config、source除了plugin目录、static、uc_client除了data目录、uc_server除了data目录`。 **当然这些也不是万无一失的方式**,重要的还是不使用弱密码和不明软件,以及个人养成安全习惯。 Last modification:October 27, 2022 © Reprint prohibited Support Appreciate the author AliPayWeChat Like If you think my article is useful to you, please feel free to appreciate