nginx rewrite base url
You really want to be matching exactly the root URL in your location block, not "absolutely everything":
location = / {
rewrite ^ /something/else break;
}
This should do the job:
location / {
rewrite ^/$ /something/else break;
}
The rewrite
statement performs an internal rewrite by default unless the target is an absolute URL or you set the redirect
or permanent
flags. Something like this would return an HTTP redirect to the client:
rewrite ^/$ /something/else redirect;