I have a wordpress blog hosted on a server (say server-blog) at, say, https://blog.example.com and our python application hosted on separate server (say server-py), url of which is https://www.example.com. To get SEO juice out of our blog on primary domain, content is proxy passed from https://blog.example.com to https://www.example.com/blog/. The configuration on the of the same is fairly simple.

SSLProxyEngine on
ProxyPass /blog/ https://blog.example.com/
ProxyPassReverse /blog/ https://blog.example.com/

Now, I'd like the https://blog.example.com domain to redirect to https://www.example.com/blog/, so that the end user is not confused as to which one is the correct URL. Since, https://www.example.com/blog/ is already proxy passed, simply adding a redirect rule will create an infinite redirect loop. I've looked into working with query string params, but proxy pass doesn't work with that.

Any ideas as to how this can be done?


Perhaps not ideal, but you could redirect/rewrite all traffic, except when the request comes from the reverse proxy (which I guess will have a static ip, say Alter the vhost for blog.example.com on server-blog and add something like:

RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4$
RewriteRule ^/(.*)$ https://www.example.com/blog/$1 [R,L]

(Not tested)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.