I want my same website to accessible from a subdirectory. For example, right now my website is


What I want is, that it should also be reachable using:


That means each path that is accessible from https://example.com should also be accessible from https://example.com/hi. How could I do this. Here is what I tried in my server config.

    location /hi {
          proxy_pass https://example.com

Right now, if I try https://example.com/hi, it gives out Bad Gateway. What is it that I should be doing?

  • You should be checking the error log. Dec 10, 2020 at 18:19

1 Answer 1


Instead of using proxy_pass did you try using rewrite?

location /hi/ {
 rewrite ^/hi(/.*)$ $1 break;
  • Could you please explain what has happened here?
    – Amanda
    Dec 13, 2020 at 6:04
  • The subdirectory /hi/ gets rewritten so for the server it looks like / was requested. No need to proxy_pass since the website is not on a remote server. Otherwise just add it.
    – unNamed
    Dec 13, 2020 at 11:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .