php - NGINX select a subfolder under the root dynamically -


i need nginx select subfolder under root folder dynamically every request based on first segment of path in url, returning 404 if subfolder doesn't exist. should made without using multiple locations.

for example, directory structure on server:

  • /services/a
  • /services/b

the url http://server/a/app.php call app.php under /services/a directory.

the url http://server/b/app.php call app.php under /services/b directory.

here standard nginx config symfony need modify:

server {     server_name _;     root /services;      location / {         try_files $uri /${nginx_entry_point}$is_args$args;     }      location ~ ^/(app_dev|config)\.php(/|$) {         fastcgi_pass app:9000;         fastcgi_split_path_info ^(.+\.php)(/.*)$;         include fastcgi_params;         fastcgi_param script_filename $realpath_root$fastcgi_script_name;         fastcgi_param document_root $realpath_root;     }      location ~ ^/app\.php(/|$) {         fastcgi_pass app:9000;         fastcgi_split_path_info ^(.+\.php)(/.*)$;         include fastcgi_params;         fastcgi_param script_filename $realpath_root$fastcgi_script_name;         fastcgi_param document_root $realpath_root;     }      location ~ \.php$ {         return 404;     }      error_log  /var/log/nginx/error.log;     access_log /var/log/nginx/access.log; } 

is possible that?


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -