可以通過修改nginx.conf配置文件實現(xiàn)。
方法如下:
禁止單目錄:
location ~* ^/attachments/.*.(php|php5)$ {deny all;}
禁止多目錄:
location ~* ^/(attachments|upload)/.*.(php|php5)$ {deny all;}
注意:
1、以上的配置文件代碼需要放到 location ~ .php{…}上面,如果放到下面是無效的。
3、不要忘記重啟nginx
service nginx restart