yangxueyou

nginx中支持.htaccess并禁止php在特定目录无法运行

Posted on 2018-01-30 12:50 杨学友 阅读(...) 评论(...) 编辑 收藏

在nginx.conf中的server里面

  include /yjdata/www/thinkphp/.htaccess;

在对应的目录下面创建.htaccess,并填写以下内容,(image是跟目下的image的一个目录,根据实际目录填写)

  

           location ~* ^/image/.*\.(php|php5)$
          {
          deny all;
          }

注意:这段配置文件一定要放在下面配置的前面才可以生效。

location ~ \.php$ { 
fastcgi_pass 127.0.0.1:9000; 
fastcgi_index index.php; 
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
include fastcgi_params; 

 

最后测试,在该目下面创建html,php,和图片看是否可以读取

如果只有php无法访问,其它的都整成打开,说明成功

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2021-11-20
  • 2022-12-23
相关资源
相似解决方案