How do I redirect a subdomain to a subdirectory in primary domain serving as reverse-proxy?
I'll describe the current setup first followed by what I'd like to change it to.
Current Setup
- Primary domain www.example.com pointing to a Ruby on Rails app deployed on Heroku.
- Wordpress blog blog.example.com running on Flywheel.
- RoR application serves as reverse-proxy to load Flywheel content under /blog subdirectory. For ex. www.example.com/blog/page1 loads content from blog.spacebox.com/page1. We're using https://github.com/waterlink/rack-reverse-proxy for making this work.
All of the above works as expected.
What We Want
Now the marketing team, wanting to up the SEO game, wants blog.example.com/* to redirect to www.example.com/blog/*
What I've Tried So Far (with failure, of course)
- Setup a Redirect on Flywheel dashboard to www.example.com/blog/$1 (expectedly resulted in infinite redirects).
- Deleted A record from DNSSimple for blog.example.com (pointing to Flywheel IP address), and replaced with a CNAME to point to www.example.com (didn't work).
With the above given stack, how can the desired result be achieved? What you recommend a stack change to achieve the outcome?
Much thanks in advance, as I've spent a good few days trying to make this work.
Comments
Post a Comment