nginx限制网站单目录执行php

还没测试过,感觉有用。

[code]
location ~^ /attachments/.*.(php|php5)?$ {
deny all;
}
禁止多目录:
location ~^ /(attachments|upload)/.*.(php|php5)?$ {
deny all;
}
[/code]

apache:
测试可用1:
[code]
RewriteEngine On
RewriteBase /
RewriteRule data/attachment/(.*).(php)$ – [F]
[/code]
2:

[code]
<Directory "D:\WWW\code\oelove\data\attachment">
<FilesMatch "\.(?i:php|php3|php4)$">
Order allow,deny
Deny from all
</FilesMatch>
</Directory>
[/code]