1

Ok, I'm not getting through this. Desired result: visiting https://mysite.local/v3.0 I'd like to serve /projects/src/index.php where my framework resides. Nginx keeps appending v3.0 to internal path. How can I avoid this? I've tried alias as well, but it seems buggy.

server {
    listen 80;
    index index.php index.html;
    server_name mysite.local;
    root /projects/src;

    location /v3.0/ {
        alias /projects/src;
        try_files $uri /index.php$is_args$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

I keep getting:

[error] 7#7: *3 open() "/projects/src/v3.0" failed (2: No such file or directory)

Could you please help me with this, I'm a newbie with nginx config...thanks.

Jumpa
  • 4,319
  • 11
  • 52
  • 100
  • Rather than using `alias`, you could try simply discarding the `v3.0` part with an internal `rewrite`, for example: `location ^~ /v3.0/ { rewrite ^/3.0(.*)$ $1 last; }` – Richard Smith Oct 31 '19 at 09:35
  • Well it's not exactly what I'm looking for. Seriuosly no way to discard the part coming from the location? – Jumpa Oct 31 '19 at 13:04
  • You could use something like the `/manage` block in [this answer](https://stackoverflow.com/questions/42443468/nginx-location-configuration-subfolders/42467562#42467562). – Richard Smith Oct 31 '19 at 13:36

0 Answers0