I am trying to wrap my head around some CGI scripting (the embedded box I’m on doesn’t quite like PHP) and I have a question about how CGI perl scripts interact with apache and some HTML sites on it.
Basically, I need part of the HTML file to load based on a config file outside of the document root. Obviously, this is where CGI steps in. Now, the problem is that CGI scripts also shouldn’t be in your doc root, so I can’t just put the script in my doc root and make it fire out HTML. So, I put my script in /var/www/cgi/, and pointed apache to it.
That part runs nicely, and it fires out an HTML page like it should. However, the original site has some resources in its doc root (css files, java applets, images, etc), that my new CGI-made HTML doesn’t have access to. So, what would be the best way to make the HTML page “build itself” off the CGI script? I have read a few things on Server side includes, which is one option. There is also the option of putting the CGI output in a <div src="script"></div>, and a couple others. The question is, what is the best way of doing this? I would appreciate any advice. Thanks beforehand!
Well, Perl might be overkill for something like that (like you said, you can do it with X-SSI), but it sounds like what you might want is to embed the fragment of Perl code into your otherwise-static HTML documents?
If you have
mod_include, you can do something like:and just have
readconfig.cgiwrite out a fragment likeYou’ll need to enable
Options +includesto parse X-SSI, possibly by dropping it in an.htaccessfile, depending on your setup…