when I use this in my server-block:
if ($http_host = "portaldemo.mydomian.tld/") {
return 301 https://portaldemo.mydomian.tld/new/path/;
}
I get redirected from my root-domain to the subpage I want. But my app doesn't work correctly anymore. How can I redirect without breaking the page?
As mentioned in the comments - there isnt enough information about the application you're using to provide a definitive answer; however, this is usually the result of the web application not being aware that it is being served from a subdirectory.
Though the resource you requested is loading, there will be other components of the application (such as css, js, images) that are requested when loading the initial resources but still reference the previous path.
For example: A web page at
/index.html
is moved to/subdir/index.html
with the following sourceThe page
index.html
will load from/subdir/index.html
however the requested resources at/mystyles.css
is no longer at that location but instead/subdir/mystyles.css
If the web application has these values hardcoded in then they will need to be manually changed to match the new address.
If the backend is dynamic in that it can globally configure the prefix (like wordpress) then you can update the prefix to
/subdir/
and the site should behave as it did previously. will load when you request the resource but the