.htaccess 将htaccess规则转换为nginx conf

.htaccess 将htaccess规则转换为nginx conf,.htaccess,nginx,rewrite,.htaccess,Nginx,Rewrite,我必须为nginx转换一些htaccess规则。对于丢失的图像,shopsystem在图像文件夹中查找,以便在运行中装入小图像。但是shopsystem只有ApacheWebServer的信息。。。。也许有人能帮我一下 RewriteCond %{REQUEST_URI} (/product_images/) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (\.jpe?g|\

我必须为nginx转换一些htaccess规则。对于丢失的图像,shopsystem在图像文件夹中查找,以便在运行中装入小图像。但是shopsystem只有ApacheWebServer的信息。。。。也许有人能帮我一下

RewriteCond %{REQUEST_URI} (/product_images/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (\.jpe?g|\.gif|\.png)$ pt_getimg.php
有人能帮我吗?它必须是第一条重写规则

目前我的conf文件:

server {
        server_tokens   off;
        listen          80;
        server_name     XXXXXXX.de;
        access_log      /var/log/nginx/MUH.XXXXXXX.de.access.log;
        error_log       /var/log/nginx/MUH.XXXXXXX.de.error.log error;

        rewrite         ^(.*)           http://www.XXXXXXX.de$1 permanent;
}

server {
        server_tokens   off;
        listen          80;
        server_name     www.XXXXXXX.de;
        access_log      /var/log/nginx/XXXXXXX.de.access.log;
        error_log       /var/log/nginx/XXXXXXX.de.error.log error;

        root            /var/www/XXXXXXX.de;
        index           index.php index.html index.htm;
        autoindex       off;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

    location ~* /XXXXXXX-backup {
        auth_basic              "Restricted";
        auth_basic_user_file    /etc/nginx/htpasswd.XXXXXXX;

        location ~ \.php$ {
                fastcgi_pass                    unix:/var/run/php5-fpm.sock;
                fastcgi_split_path_info         ^(.+\.php)(/.+)$;
                fastcgi_intercept_errors        on;
                include                         /etc/nginx/fastcgi_params;
        }
    }

        location / {
                try_files $uri $uri/ /index.php?$args;
        }


        location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|ttf)$ {
                expires max;
                #log_not_found off;
        }

        if (!-e $request_filename) {
    rewrite /(.*/)?Blog/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+).html.* /blog.php?blog_cat=$2&blog_item=$3 last;
    rewrite /(.*/)?Blog/([A-Za-z0-9_-]+)/?.* /blog.php?blog_cat=$2 last;
    rewrite /(.*/)?Blog/ /blog.php last;
    rewrite /(.*/)?info/([A-Za-z0-9_-]+).html.* /shop_content.php?gm_boosted_content=$2&$args last;
    rewrite /(.*/)?([A-Za-z0-9_-]+).html /product_info.php?gm_boosted_product=$2&$args last;
    rewrite /(.*/)?([A-Za-z0-9_-]+)/?.* /index.php?gm_boosted_category=$2&$args last;
    rewrite /(.*/)?Blog/([A-Za-z0-9_-]+)/?.* /blog.php?blog_cat=$2 last;
        }

        location ~ \.php$ {
                fastcgi_pass                    unix:/var/run/php5-fpm.sock;
                fastcgi_split_path_info         ^(.+\.php)(/.+)$;
                fastcgi_intercept_errors        on;
                include                         /etc/nginx/fastcgi_params;
        }

}

对不起,我的英语不好,希望你能阅读和理解。谢谢。

在Apache中,重写通常是通过nginx中的位置匹配来完成的:

location /product_images/ {
    try_files $uri @get_img;
}

location @get_img {
    rewrite ^.*$ /product_images/pt_getimg.php;
}

如果,请不要使用
:为什么从不使用?我是nginx的新手