I'm trying to redirect requests from
example.com/abc234
to
example.com/setup.html?s=abc234
So far, I've tried the following, but it seems to always end up either 1) not transmitting the parameter or 2) ending up in an infinite loop (or 404) because it also tries to redirect the redirected request? The request has to be visibly rewritten because I want to pick up the parameter with JS, not PHP.
server {
server_name example.com;
root /var/www/html;
rewrite ^(.*)$ /setup.html?s=$1 redirect;
}
I've also tried various combinations of location / { try_files ...; }
or using the absolute URL within rewrite
without success.
One technique is to rewrite only URIs that do not match a physical file.
For example:
See this document for more. rewrite ^(.*)$ /setup.html?s=$1 redirect; }