Forum Moderators: coopster & phranque

Message Too Old, No Replies

Using server includes in CGI search script

Included headers and footers not recognized

         

aus_dave

3:56 am on Jan 6, 2003 (gmt 0)

10+ Year Member



I'm installing a CGI search script on my site (Perlfect Search, it looks pretty good ;)).

I want to customise the results page to fit the look of my site. My site's pages use two include files, header.ssi and footer.ssi. Perfect Search has a search.html template that I have edited to include these files and it looks ok when previewed locally.

However, when run on the server the header and footer includes aren't recognised i.e. I can see the include statement in the source code. Are there any CGI gurus that can point me in the right direction to fix this?

I could substitute the includes for the actual HTML code if I had to but that sort of defeats the purpose of include files, doesn't it? :).

jdMorgan

5:27 am on Jan 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



aus_dave,

Make sure you have configured your server to enable it to parse the output of the script for Server-Side Includes. Without more details of your server type and file naming, that's as far as I can go...

Jim

aus_dave

5:36 am on Jan 6, 2003 (gmt 0)

10+ Year Member



Thanks Jim, it's an Apache server out of interest and the script uses .cgi and .pl modules. I'll look around for some more info on this. Not having any luck doing this with .htaccess, I have edited it before to allow parsing of html/htm extensions as well as shtml for includes.

volatilegx

5:22 pm on Jan 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem is due to the fact that you're using Server Side Includes on a page generated by a CGI script. That's a no-no.

Server Side Includes are parsed by the server when read from a .shtml file. However, when output is generated by a CGI script, it is not parsed by the server in this fashion, so the SSI calls aren't recognized by the server.

Instead of using SSI calls, you could edit the CGI script and have it read the same file the SSI did and insert it into the results. Here's a couple of lines you could insert that would accomplish this:

use LWP::Simple;
$SSIheader = get "http://www.yourdomain.com/cgi-bin/header.cgi";
$SSIfooter = get "http://www.yourdomain.com/cgi-bin/footer.cgi";
print $SSIheader;
print $SSIfooter;

These lines could be used to execute the cgi-script that would normally be called by the SSI call. You would replace the SSI calls with these lines. Note that this would go into the search CGI script itself, not into any template that script used.

bird

5:36 pm on Jan 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It all depends on the version of apache you're running. The newest ones (2.x.something) are actually able to apply SSI to the output of CGI scripts. If you're stuck with the 1.x series, then you'll have to imitate the effect within your script.

volatilegx

8:16 pm on Jan 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wow, bird, I wasn't aware of that. Maybe it's time to upgrade ;)

aus_dave

11:08 pm on Jan 15, 2003 (gmt 0)

10+ Year Member



Thanks volatilegx and bird - more food for thought ;).

$SSIheader = get "http://www.yourdomain.com/cgi-bin/header.cgi";

Now I'm confused - shouldn't this be domain.com/header.ssi?

I eventually pasted the include files into the template but I will try and get this working as you suggest :).

gbizeau

8:39 pm on Jan 16, 2003 (gmt 0)

10+ Year Member



>>Now I'm confused - shouldn't this be domain.com/header.ssi?

yes

andreasfriedrich

9:24 pm on Jan 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>Now I'm confused - shouldn't this be domain.com/header.ssi?

yes

I´m not quite sure about this definite yes. While the LWP::Simple [search.cpan.org] pod page does not say so explicitly I do believe that get [search.cpan.org] expects absolute URIs. Only when using SSI the authority part of the URI is not allowed.

Andreas

volatilegx

3:28 pm on Jan 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



aus_dave,

LWP::Simple expects absolute URLs.

When I put that example URL in there, I thought you were using SSI to call a CGI script that generated the header. If you are simply including the contents of a text file, then you would call that text file directly, so it would have to point to header.ssi