自定义nginx php-fpm多规则,如.httaccess

时间:2019-06-12 07:57:35

标签: php nginx centos

我正在尝试在nginx php-fpmvesta cp centos 6中转换我的.httaccess规则。此函数用于更改图像大小并添加水印。但不幸的是,当我要求链接页面显示所有php代码而不执行php代码时。

请求:http://bind.pk/uploads/products/large/item2_33_1414578132.jpg

result: <?php include_once('../../apanel/common.php');
    include('../../includes/globalfnc.php');if($_REQUEST['act']=='watermark'){
    shonirwatermarkfnc($_REQUEST['img']);
    }else{
    shonirresizefnc($_REQUEST['img'],$_REQUEST['width'], $_REQUEST['height']);  
    }exit;?>

我正试图从12小时开始解决此问题,但未找到解决方案。

server {

    listen      13.112.240.26:80;
    server_name bind.pk www.bind.pk;
    root        /home/bindpk/web/bind.pk/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/bind.pk.log combined;
    access_log  /var/log/nginx/domains/bind.pk.bytes bytes;
    error_log   /var/log/nginx/domains/bind.pk.error.log error;


location / {
        try_files $uri $uri/ @opencart;
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ 
{
            expires     max;
        }


        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }
            fastcgi_pass    127.0.0.1:9014;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
}


location ^~ /uploads {

rewrite ^/uploads/products/thumbnail/([^./]+).([^./]+)$ /uploads/items/image.php?act=resize&width=212&height=212&img=$1.$2 last;

rewrite ^/uploads/products/small/([^./]+).([^./]+)$ /uploads/items/$1.$2 last;

rewrite ^/uploads/products/large/([^./]+).([^./]+)$ /uploads/items/image.php?act=watermark&img=$1.$2 last;

 }


location @opencart {

rewrite ^/(.+)$ /index.php?_route_=$1 last;

   }

    location /vstats/ {
        alias   /home/bindpk/web/bind.pk/stats/;
        include /home/bindpk/conf/web/bind.pk.auth*;
    }
    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;
    location /error/ {
        alias   /home/bindpk/web/bind.pk/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;
    include     /home/binpk/conf/web/nginx.bind.pk.conf*;

0 个答案:

没有答案