We had an file drive application served by apache running on the following path:
https://app.example.com/app
We were required to update the app and change to use Nginx. We were also tasked to serve the application on:
https://app.example.com
However, we still have some files referencing the first path and we would like those paths to be accessible. For now, we can only serve files using the second path. My nginx configuration file is:
server {
listen 80;
listen [::]:80;
server_name app.example.com;
# Force HTTPS redirection
return 301 https://$http_host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name app.example.com;
ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
root /var/www/html;
index index.php;
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set $path_info $fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
}
}
Given the configuration, I would love to serve both app.example.com
and app.example.com/app
with the same application files on the server. I tried using this:
location /app {
rewrite ^/app(.*) /$1 last;
}
But it simply redirects all requests and I am unable to properly load a file for example with https://app.example.com/file?id=12345
. I would appreciate any assistance in solving this. Thanks!