I have a bunch of subdomains in one single server:
- a.example.com
- b.example.com
- news.example.com
All of them are in the same Apache virtualhost.
I need to use a feed provided by the news subdomain inside the a and b subdomain. The feeds typically look like this:
- news.example.com/news/a
- news.example.com/news/b
On the a and b subdomains, I'm using jquery's ajax function to load the data from the news feeds, and present it on a and b. This initially didn't work, because of the same-origin policy.
I was able to override this by adding the Access-Control-Allow-Origin "*"
to my Apache config file.
... but this works only in Firefox, Chrome and Safari. Internet explorer seems to ignore that directive.
Thus, I need to create a proxy.
What I need is a new directory in all my subcomains (for example /proxy
) that Apache detects, and redirects to news.example.com, no matter what the subdomain. So:
- a.example.com/proxy/news/a -> return the contents of news.example.com/news/a
- b.example.com/proxy/news/b -> return the contents of news.example.com/news/b
Can I do this directly in Apache + submodules (for example, mod_rewrite), or do I need to use a scripting language like PHP for doing this?