Nginx重定向文件php

时间:2018-12-05 10:00:43

标签: php symfony nginx redirect

我在重定向php文件时遇到问题。我想将旧文件.php重定向到新站点(使用Symfony 3)

我的配置nginx:

map_hash_max_size 512;
map_hash_bucket_size 512;
map $request_uri $redirect {
    include /etc/nginx/.redirects;
}    
server {
    listen 80 default_server;
    server_name default_server;    
    gzip on;
    [...]
    root /server/web;

    # custom redirects
    if ($redirect) {
        return 301 $redirect;
    }

    rewrite ^/(.*)/$ /$1 permanent;

    location / {
        try_files $uri /app_dev.php$is_args$args;
    }

    location ~ ^/(app_dev|config)\.php(/|$) {
        fastcgi_param QUERY_STRING    $query_string;
        fastcgi_param CONTENT_TYPE    $content_type;
        fastcgi_param CONTENT_LENGTH  $content_length;
        fastcgi_param REQUEST_URI     $request_uri;
        fastcgi_param REQUEST_METHOD  $request_method;
        fastcgi_param REMOTE_ADDR     $realip_remote_addr;
        fastcgi_param SCRIPT_FILENAME /server/web/app_dev.php;
        fastcgi_param SCRIPT_NAME     app_dev.php;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
    }

    location ~ \.php$ {
        return 404;
    }

}

和/etc/nginx/.redirects

/old_site /new_site
/old_site_2?test=222 /new_site_22222
/old_file.php /new_file

没有* .php的所有作品

为什么不起作用?

谢谢

@up

0 个答案:

没有答案