How can I rewrite URLs in XML with Apache 2.4?

1.9k views Asked by At

Apache 2.4 includes mod_proxy_html and that's great, it's catching all kinds of URLs inside the HTML coming back from the server and fixing them. But I've got a Seam app that sends back text/xml files to the client sometimes with fully qualified URLs that also need to be rewritten and mod_proxy_html doesn't fix them.

Apparently there was a mod_proxy_xml that used to exist separately from mod_proxy_html but Apache didn't include that. Is there a way to get mod_proxy_html configured to do the same thing? I need it to fix URLs in both the HTML and XML files coming back from a server.

Follow up:

I continue to fight with this and I've tried a few different solutions with no success including using mod_substitute (which somehow I'm configuring incorrectly because it never seems to substitute anything for anything) and using the force flag mod_proxy_html has to try and force it to do all files under a certain path.

1

There are 1 answers

0
Murilo Yoshida On

This is an old question, but I just faced the same issue. I tried with mod_proxy_html, compiled mod_proxy_xml, nothing worked.

@JonLin's suggestion is spot on, it works with mod_sed. The only if is mod_sed is documented to work inside Directory nodes. If you declare a Location though and do a SetOutputFilter instead of AddOutputFilter (which requires a mime type) it works beautifully.

The config that works is:

<Location "/">
    SetOutputFilter Sed
    OutputSed "s,http://internal:80,https://external.com,g"
</Location>