Apache2-ModProxyPerlHtml

 view release on metacpan or  search on metacpan

ModProxyPerlHtml.pm  view on Meta::CPAN


Note that here FilterHandlers are set globally, you can also set them in any
<Location> part to set it locally and avoid calling this Apache module globally.

If you want to rewrite some code on the fly, like changing images filename you
can use the perl variable ProxyHTMLRewrite under the location directive as
follow:

    <Location /webcal/>
        ...
        PerlAddVar ProxyHTMLRewrite "/logo/image1.png /images/logo1.png"
	# Or more complicated to handle space in the code as space is the
	# pattern / substitution separator character internally in ModProxyPerlHtml
	PerlAddVar ProxyHTMLRewrite "ajaxurl[\s\t]*=[\s\t]*'/blog' ajaxurl = '/www2.mydom.org/blog'"
        ...
    </Location>

this will replace each occurence of '/logo/image1.png' by '/images/logo1.png' in
the entire stream (html, javascript or css). Note that this kind of substitution
is done after all other proxy related replacements.

In some conditions javascript code can be replaced by error, for example:

        imgUp.src = '/images/' + varPath + '/' + 'up.png';

will be rewritten like this:

        imgUp.src = '/URL/images/' + varPath + '/URL/' + 'up.png';

To avoid the second replacement, write your JS code like that:

        imgUp.src = '/images/' + varPath + unescape('%2F') + 'up.png';

ModProxyPerlHTML replacement is activated on certain HTTP Content Type. If you
experienced that replacement is not activated for your file type, you can use the
ProxyHTMLContentType configuration directive to redefined the HTTP Content Type
that should be parsed by ModProxyPerlHTML. The default value is the following
Perl regular expresssion:

	PerlAddVar ProxyHTMLContentType    (text\/javascript|text\/html|text\/css|text\/xml|application\/.*javascript|application\/.*xml)

If you know exactly what you are doing by editing this regexp fill free to add

README  view on Meta::CPAN

    Note that here FilterHandlers are set globally, you can also set them in
    any <Location> part to set it locally and avoid calling this Apache
    module globally.

    If you want to rewrite some code on the fly, like changing images
    filename you can use the perl variable ProxyHTMLRewrite under the
    location directive as follow:

        <Location /webcal/>
            ...
            PerlAddVar ProxyHTMLRewrite "/logo/image1.png /images/logo1.png"
            # Or more complicated to handle space in the code as space is the
            # pattern / substitution separator character internally in ModProxyPerlHtml
            PerlAddVar ProxyHTMLRewrite "ajaxurl[\s\t]*=[\s\t]*'/blog' ajaxurl = '/www2.mydom.org/blog'"
            ...
        </Location>

    this will replace each occurence of '/logo/image1.png' by
    '/images/logo1.png' in the entire stream (html, javascript or css). Note
    that this kind of substitution is done after all other proxy related
    replacements.

    In some conditions javascript code can be replaced by error, for
    example:

            imgUp.src = '/images/' + varPath + '/' + 'up.png';

    will be rewritten like this:

            imgUp.src = '/URL/images/' + varPath + '/URL/' + 'up.png';

    To avoid the second replacement, write your JS code like that:

            imgUp.src = '/images/' + varPath + unescape('%2F') + 'up.png';

    ModProxyPerlHTML replacement is activated on certain HTTP Content Type.
    If you experienced that replacement is not activated for your file type,
    you can use the ProxyHTMLContentType configuration directive to
    redefined the HTTP Content Type that should be parsed by
    ModProxyPerlHTML. The default value is the following Perl regular
    expresssion:

            PerlAddVar ProxyHTMLContentType    (text\/javascript|text\/html|text\/css|text\/xml|application\/.*javascript|application\/.*xml)



( run in 0.929 second using v1.01-cache-2.11-cpan-df04353d9ac )