Let's say there's a domain, xyz.com, registered and managed at DNSSimple. A Rails application is configured to serve a website at https://www.xyzDOTcom. There's also a sub-domain, https://get.xyzDOTcom that is configured to serve several landing pages set up using Unbounce.
Now, the SEO guy wants all the Unbounce pages to be made accessible via https://www.xyzDOTcom/storage/PAGE. I implemented this by adding Rack's reverse-proxy to the config.ru.
Problem - The SEO guy also wants the existing https://get.xyzDOTcom/PAGE URLs to redirect (301) to their corresponding https://www.xyzDOTcom/storage/PAGE counterparts. Unbounce allows embedding custom Javascript blogs to its pages, so I tried window.location = , window.location.replace(), window.location.href = etc, but they all resulted in an infinite redirect loop when trying to access https://get.xyzDOTcom/PAGE.
How do I achieve this 301 redirect of https://get.xyzDOTcom/PAGE to the corresponding reverse-proxy https://www.xyzDOTcom/storage/PAGE?
How about
get2.xyzDOTcomget2.xyzDOTcominstead ofget.xyzDOTcomget2.xyzDOTcomget.xyzDOTcomwww.xyzDOTcomNote: If the whole exercise is because of SEO, it might be a bad idea to do a JavaScript redirect anyway.
Note 2: Don't know if that is an option for you, but Cloudflare Page Rules would make this a no-brainer.