i tried setting up my php backend and my vue on the same location. Based on the X-Requested-With
header the server should decide if the backend would be used or the vue should be delivered. Now the delivery of the vue file is working, but the php is not executed.
info: at the position of X-URI the $uri
is /index.php
, but it is not running php
# Backend if ($http_x_requested_with = "XMLHttpRequest") { set $INDEX "index.php"; set $DOCOUMENTROOT "C:/server/web/www/altv_gadget/public"; set $SERVING "LaminasMVC"; } # Vue Frontend if ($http_x_requested_with != "XMLHttpRequest") { set $INDEX "index.html"; set $DOCOUMENTROOT "C:/server/web/www/altv_gadget/dist"; set $SERVING "Vue"; } # Directory Indexes index $INDEX; # Document Root root $DOCOUMENTROOT; # Serving Header add_header X-Serving $SERVING; # Location location / { try_files $uri $uri/ /index.php$is_args$args /index.html$is_args$args; } add_header X-URI $uri; # For PHP files, pass to php_farm location ~ .php$ { add_header X-PHP "1"; fastcgi_pass php_farm; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
I hope somebody has an idea how to fix this.
Advertisement
Answer
I dont know what was my issue, but it seems to work know. For my specific solution i went with try_files $uri $uri/ /$INDEX$is_args$args;
to use either my index.html
or index.php
based on my param.