我正在寻找解决此问题的方法,
我喜欢将我的环境称为第一个url参数,第二个应该是symfony应该获得的真实网址。
示例: test.local的/ dev / URL 要么 test.local / PROD / URL
但是我无法通过nginx从URL中删除环境,以便symfony获得他需要的真正url女巫,我总是从symfony获得404
upstream php {
server unix:/var/run/php5-fpm.socket;
}
map $http_host $SYMFONY_ENV {
~^test.test "test";
default "dev";
}
map $uri $PLATFORM {
~^/(?<platform>[a-z_-]+)/.* $platform;
}
underscores_in_headers on;
server {
listen 80;
listen 443 ssl;
listen 8280;
listen 8443 ssl;
# Make site accessible from
server_name test.dev test.test;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
set $port 8280;
if ($scheme = 'https') {
set $port 8443;
}
# strip app.php/ prefix if it is present
access_log /var/log/nginx/access-dev.log;
error_log /var/log/nginx/error-dev.log;
root /var/www/web;
index app.php;
rewrite ^/app\.php/?(.*)$ /$1 permanent;
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
location / {
location ~ .*\.php(/|$) {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.socket;
fastcgi_read_timeout 300;
fastcgi_buffer_size 256k;
fastcgi_buffers 4 256k;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index app.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param DOCUMENT_ROOT $realpath_root;
include fastcgi_params;
fastcgi_param SYMFONY_ENV $SYMFONY_ENV;
fastcgi_param SYMFONY_DEBUG 1;
fastcgi_param SYMFONY_CACHE 0;
fastcgi_param SYMFONY__PLATFORM $PLATFORM;
}
try_files $uri @rewriteapp;
}
location ~ ^/assets/(.*)$ {
try_files /uploads/$subsite/published/$1 /app.php;
}
location ~* .(png|jpeg|jpg|gif|svg)$ {
try_files /uploads/$subsite/$1 /web/$1 /app.php;
}
}