Windows虚拟主机禁用脚本执行权限方法

时间:2022-06-01 12:55:56

如果您使用的是Windows虚拟主机,需要禁止某个目录的脚本执行权限,您可以在要禁用脚本执行权限的目录建立一个web.config文件,里面加入下面的代码:

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <configuration> 
  3.     <system.webServer> 
  4.         <handlers> 
  5.             <remove name="ASPClassic" /> 
  6.             <remove name="PHP-FastCGI" /> 
  7.             <remove name="ASPNET-ISAPI-1.1-AXD" /> 
  8.             <remove name="ASPNET-ISAPI-1.1-HttpRemotingHandlerFactory-rem" /> 
  9.             <remove name="ASPNET-ISAPI-1.1-HttpRemotingHandlerFactory-soap" /> 
  10.             <remove name="ASPNET-ISAPI-1.1-PageHandlerFactory" /> 
  11.             <remove name="ASPNET-ISAPI-1.1-SimpleHandlerFactory" /> 
  12.             <remove name="ASPNET-ISAPI-1.1-WebServiceHandlerFactory" /> 
  13.             <remove name="AssemblyResourceLoader-Integrated" /> 
  14.             <remove name="AXD-ISAPI-2.0" /> 
  15.             <remove name="AXD-ISAPI-2.0-64" /> 
  16.             <remove name="HttpRemotingHandlerFactory-rem-Integrated" /> 
  17.             <remove name="HttpRemotingHandlerFactory-rem-ISAPI-2.0" /> 
  18.             <remove name="HttpRemotingHandlerFactory-rem-ISAPI-2.0-64" /> 
  19.             <remove name="HttpRemotingHandlerFactory-soap-Integrated" /> 
  20.             <remove name="HttpRemotingHandlerFactory-soap-ISAPI-2.0" /> 
  21.             <remove name="HttpRemotingHandlerFactory-soap-ISAPI-2.0-64" /> 
  22.             <remove name="PageHandlerFactory-Integrated" /> 
  23.             <remove name="PageHandlerFactory-ISAPI-2.0" /> 
  24.             <remove name="PageHandlerFactory-ISAPI-2.0-64" /> 
  25.             <remove name="Perl-CGI" /> 
  26.             <remove name="Perl-ISAPI" /> 
  27.             <remove name="rules-64-ISAPI-2.0" /> 
  28.             <remove name="rules-Integrated" /> 
  29.             <remove name="rules-ISAPI-2.0" /> 
  30.             <remove name="SecurityCertificate" /> 
  31.             <remove name="SimpleHandlerFactory-Integrated" /> 
  32.             <remove name="SimpleHandlerFactory-ISAPI-2.0" /> 
  33.             <remove name="SimpleHandlerFactory-ISAPI-2.0-64" /> 
  34.             <remove name="svc-Integrated" /> 
  35.             <remove name="svc-ISAPI-2.0" /> 
  36.             <remove name="svc-ISAPI-2.0-64" /> 
  37.             <remove name="TraceHandler-Integrated" /> 
  38.             <remove name="TRACEVerbHandler" /> 
  39.             <remove name="WebAdminHandler-Integrated" /> 
  40.             <remove name="WebServiceHandlerFactory-Integrated" /> 
  41.             <remove name="WebServiceHandlerFactory-ISAPI-2.0" /> 
  42.             <remove name="WebServiceHandlerFactory-ISAPI-2.0-64" /> 
  43.             <remove name="xoml-64-ISAPI-2.0" /> 
  44.             <remove name="xoml-Integrated" /> 
  45.             <remove name="xoml-ISAPI-2.0" /> 
  46.         </handlers> 
  47.     </system.webServer> 
  48. </configuration> 

保存后就设置了该文件夹以及子容器只有读和写的权限,而没有脚本执行权限。如果要恢复脚本权限就直接删除该目录下的web.config文件。