location ~* /(js|css|public|uploadfile|images|less|font_icon|bootstrap)/(.*).(php)$ {
    return 403;
    }

宝塔面板 nginx 禁止执行php 记得放在php版本前面:include enable-php-70.conf; 



RewriteEngine on
#安全设置 禁止以下目录运行指定php脚本
RewriteCond % !^$
RewriteRule a/(.*).(php)$ – [F]
RewriteRule data/(.*).(php)$ – [F]
RewriteRule templets/(.*).(php|htm)$ – [F]
RewriteRule uploads/(.*).(php)$ – [F]

以上代码:如果你的php运行环境是apache,可使用 .htaccess 文件来设置,



<rule name="Block data" stopProcessing="true">
	<match url="^data/(.*).php$" />
	<conditions logicalGrouping="MatchAny">
		<add input="{USER_AGENT}" pattern="data" />
		<add input="{REMOTE_ADDR}" pattern="" />
	</conditions>
	<action type="AbortRequest" />
</rule>
<rule name="Block templets" stopProcessing="true">
	<match url="^templets/(.*).php$" />
	<conditions logicalGrouping="MatchAny">
		<add input="{USER_AGENT}" pattern="templets" /> <add input="{REMOTE_ADDR}" pattern="" />
	</conditions>
	<action type="AbortRequest" />
</rule>
<rule name="Block SomeRobot" stopProcessing="true">
	<match url="^uploads/(.*).php$" />
	<conditions logicalGrouping="MatchAny">
		<add input="{USER_AGENT}" pattern="SomeRobot" />
		<add input="{REMOTE_ADDR}" pattern="" />
	</conditions>
	<action type="AbortRequest" />
</rule>

windows php环境


发表评论 已发布 0

还可以输入 800 个字
 
 
打印