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