I'm trying to set up a location such that suffix /reset_password/any_text would load index.html from the directory specified in the alias. Unfortunately, with no luck...
# location /reset_password { # alias /var/www/grades-ui; # } location /reset_password/([0-9a-z]*) { alias /var/www/grades-ui; } The commented out code works fine to load exact path /reset_password, however my goal is to serve /reset_password/any_text_or_number.
Any ideas why my regular expression wouldn't work? Or maybe I'm doing something else completely wrong?
Edit: the complete conf file
server { listen 443 ssl; # managed by Certbot root /var/www/grades-ui; server_name www.mygrades.co.uk mygrades.co.uk; ssl_certificate /etc/letsencrypt/live/mygrades.co.uk/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/mygrades.co.uk/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot location / { index index.html; add_header X-debug-message "Location / reached" always; } location ^~ /reset_password/(.*)[a-z]/ { alias /var/www/grades-ui; add_header X-debug-message "Location /reset_password/$1 reached" always; } location ^~ /reset_password { alias /var/www/grades-ui; add_header X-debug-message "Location /reset_password reached" always; } # location /reset_password/([0-9a-z]*) { # root /var/www/grades-ui; # try_files /index.html =404; # } } server { listen 80; if ($host = mygrades.co.uk) { return 301 $host$request_uri; } # managed by Certbot server_name www.mygrades.co.uk mygrades.co.uk; # return 301 https://$host$request_uri; # managed by Certbot proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
location /reset_password { root /var/www/grades-ui; try_files /index.html =404; }https://mygrades.co.uk/reset_password/test/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/