We are using Nginx and need to redirect requests from one domain to another. Both domains are virtual servers configured properly in Virtualmin.
On the source domain (the one I want to redirect requests from), I've set up a redirect using the Server Configuration > Website Redirects feature. I set the source URL to "/", the destination URL to https://www.example.com/$1, the redirect type to permanent (301), and have chosen to include subpaths in the redirect. Saving my changes produces no errors.
However, when I go in and edit the redirect to verify everything, the redirect type is set back to default. If I set it to permanent, save my changes, and then go back and edit the redirect again, it is back to being set at default.
Looking at the raw virtual host configuration file, this is what it shows:
rewrite ^/(?!.well-known)(.*) https://www.example.com/ break;
When, according to the Nginx documentation, permanent redirects should look like this:
rewrite ^/(?!.well-known)(.*) https://www.example.com/ permanent;
Making this change manually in the virtual server configuration file and then restarting Nginx results in the correct 301 redirect.
Upon further investigation, it appears the rewrite rule doesn't actually include subpaths as I specified in the Virtualmin redirect configuration. A permanent redirect line that causes subpaths to work properly should look like this:
rewrite ^/(?!.well-known)(.*)$ https://www.example.com/$1 permanent;