0

The webpages are accecced in the following manner:

example.com/?site=website 

In this example, I'm accessing the website located on example.com domain.

Could anyone suggest an optimal way of rewriting rules, so the above would be shown and accessed by example.com/website?

nginx, Centos 7
1

You can use the following, remembering that IfIsEvil

location = / {
  if ($arg_site) {
    return 302 /$arg_site;
  }
}
0

Related:

The idea is you create a redirect loop, but not really, since there is a difference between external v. internal redirects, so, the loop is not a closed one, because one redirect is explicitly only external, whereas the other one is explicitly only internal:

location = / {
    if ($arg_site) {
        return  302 /$arg_site;
    }
    return  200
    "<!DOCTYPE html><title>site</title>
    <form><input name='site' value='website'/></form>\n";
}
location / {
    rewrite     ^/([^/]*)\$     /?site=$1   break;
    proxy_pass  http://javabackend:8080;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.