我想在Symfony2项目中分离我的主应用程序和XHR请求。
以下是我的常规Sf2控制器:
https://www.example.com/*
=> /web/app.php/*
https://www.example.com/app_dev.php/*
=> /web/app_dev.php/*
但是我想添加类似的XHR请求(在同一个域上,以避免CORS问题):
https://www.example.com/xhr/*
=> /web/xhr.php/*
(不需要开发环境)我正在尝试创建一个nginx vhost,但我找不到正确的方法:
server {
listen 443 default_server ssl;
server_name www.example.com;
root /var/www/example.com/current/web;
include ssl_config.conf;
location /xhr {
try_files $uri /xhr.php$is_args$args;
}
location / {
try_files $uri /app.php$is_args$args;
}
location ~ ^/(app|app_dev|xhr)\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
}
}
答案 0 :(得分:0)
您的配置将在重定向期间删除pathinfo。也许你应该使用:
try_files $uri /xhr.php$uri$is_args$args;
或简单地说:
try_files $uri /xhr.php$request_uri;