I have a portal that is under a virtual host in Apache. All lot of its .css and .js is generated dynamically by the underlying tomcat web application. What I want to do is inject some of my own .css and .js into the mix before it is served. I think I need something like mod_rewrite but for html.
I know I could try to piggyback onto some resource reference that is used on every page and use mod_rewrite that way, but that is hard to do and I need my css to be applied last.
Tell me there are some magic beans for this. I just need to inject a couple scripts and styles right at </head>.
I haven't used it before, but it looks like mod_ext_filter could do this
By looking at the example, you could try the following Perl script
#!/usr/local/bin/perl -w
use strict;
my $extraCode = "<script src=\"http:/...\"></script>";
while (<STDIN>) {
s/<\/head>/$extraCode<\/head>/i;
print;
}
After I posted this, I noticed someone recommended https://serverfault.com/questions/46449/how-to-inject-html-code-into-every-delivered-html-page. mod_proxy_html and mod_sed looks good
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With