<div dir="ltr">Hi there,<div><br></div><div>I am currently somewhat stuck getting the following setup up and running:</div><div><br></div><div>I have one PHP web application residing in /usr/share/a that I'd like to have available at /. This works as expected.</div>

<div><br></div><div>I have a second PHP web app residing in /var/www/b/public, that I'd like to have available at /b.</div><div><br></div><div>My current ngnix (1.2.1) configuration looks like this:</div><div><br></div>

<div>-- 8< --</div><div><div>server {</div><div>  listen       *:443 ssl;</div><div>  listen [::]:443 ;<br></div><div>  </div><div>  [...]</div><div><br></div><div>  root /usr/share/a;<br></div><div>  index  index.php;</div>

<div><br></div><div>  location ~ ^/b/.*\.php$ {</div><div>    rewrite         ^/b(/.*) $1 break;</div><div>    root  /var/www/b/public;</div><div>    include /etc/nginx/fastcgi_params;</div><div>    fastcgi_pass unix:/var/run/php5-fpm.sock;</div>

<div>  }</div><div><br></div><div>  location ~ \.php$ {</div><div>    include /etc/nginx/fastcgi_params;</div><div>    fastcgi_pass unix:/var/run/php5-fpm.sock;</div><div>  }</div><div><br></div><div>  location ~ ^/b/ {</div>

<div>    root  /var/www/b/public;</div><div>    index  index.php;</div><div>  }</div><div>}<br></div></div><div>-- 8< --</div><div><br></div><div>/etc/nginx/fastcgi_params:<br></div><div>-- 8< --</div><div>fastcgi_param   QUERY_STRING              $query_string;</div>

<div>fastcgi_param   REQUEST_METHOD    $request_method;</div><div>fastcgi_param   CONTENT_TYPE              $content_type;</div><div>fastcgi_param   CONTENT_LENGTH    $content_length;</div><div><br></div><div>fastcgi_param   SCRIPT_FILENAME   $request_filename;</div>

<div>fastcgi_param   SCRIPT_NAME                 $fastcgi_script_name;</div><div>fastcgi_param   REQUEST_URI                 $uri?$args;</div><div>fastcgi_param   DOCUMENT_URI              $document_uri;</div><div>fastcgi_param   DOCUMENT_ROOT             $document_root;</div>

<div>fastcgi_param   SERVER_PROTOCOL   $server_protocol;</div><div><br></div><div>fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;</div><div>fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;</div><div><br></div>

<div>fastcgi_param   REMOTE_ADDR                 $remote_addr;</div><div>fastcgi_param   REMOTE_PORT                 $remote_port;</div><div>fastcgi_param   SERVER_ADDR                 $server_addr;</div><div>fastcgi_param   SERVER_PORT                 $server_port;</div>

<div>fastcgi_param   SERVER_NAME                 $server_name;</div><div><br></div><div>fastcgi_param   HTTPS                           $https;</div><div><br></div><div># PHP only, required if PHP was built with --enable-force-cgi-redirect</div>

<div>fastcgi_param   REDIRECT_STATUS         200;</div><div>-- 8< --</div><div><br></div><div>I included the rewrite in location ~ ^/b/.*\.php$ because otherwise nginx/php-fpm will look for the script /b/index.php in /var/www/b/public/b/index.php, which has an extra "b/" in the path.</div>

<div><br></div><div>With the rewrite enabled, however, the PHP application guesses its own path incorrectly issuing redirects to locations that leave out "/b'.</div><div><br></div><div>I would like to avoid symlinking /var/www/b into /usr/share/a.</div>

<div><br></div><div>Any ideas?</div><div><br></div><div>Thanks,<br>Thilo</div></div>