sub.mydomain.com redirect to mydomain.com/sub with Forge|Digital Ocean
I have wildcard subdomains setup with ssl cert. I want to accomplish this:
sub.mydomain.com redirects 301 to mydomain.com/sub
Seems like this should be easy... but
1. Can't add /sub to a dns record at Digital Ocean.
2. Can't get the Forge redirects from the panel to work (probably syntax).
3. Don't know enough to edit the Nginx Config file
***bonus - would love to have subs not redirected to hit a 404 location...
You can't add "/sub" to DNS records. Instead you would need to setup a wildcard (*.mydomain.com) CNAME record to point to your main app domain and in Forge check "Allow Wildcard Sub-Domains" when setting up your site.
Then you can use subdomain-routing as per link above and check for the existence of a sub domain and redirect and 404 if it doesn't exist.