0

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

https://example.com

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

https://example.com/hi

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?

Amanda
  • 125
  • 1
  • 6

1 Answers1

0

Instead of using proxy_pass did you try using rewrite?

location /hi/ {
 rewrite ^/hi(/.*)$ $1 break;
}
unNamed
  • 545
  • 2
  • 11
  • Could you please explain what has happened here? – Amanda Dec 13 '20 at 06: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 '20 at 11:56