PDA

View Full Version : CGI and SSI together?


sgtaw
01-03-2009, 12:04 AM
Hi All,

Don't know if this is the right place.

I am creating a website that uses ssi to add in the navigation. This is so the updating of the navigation across the site is simple -- one file...

Then, I have pages that execute a CGI script to get search engine results.

The problem I am having is that I can't get the cgi execution AND the SSI execution to work together. Either one work and not the other or vice versa.

So here is the general code for a page....

--------------BEGIN---------------
<!--#include virtual="../search.cgi/?&keywords=test+code" -->

<?php include($_SERVER['DOCUMENT_ROOT']."/left-navigation.php"); ?>
------------END-----------------

"left-navigation.php" is just standard html.

The current .htaccess that I have is
---------------BEGIN-----------------
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)\.html$ /search.cgi/?keywords=$1

Options +execCGI +Includes

AddHandler cgi-script .cgi .pl
Order deny,allow
AddType text/html shtml html php
AddHandler server-parsed shtml html php
AddHandler application/x-httpd-php .php .html .htm .shtml
AddHandler application/x-httpd-php5 .php .html .htm .html .shtml
----------END----------

Using the above htaccess, the navigation shows up but the cgi is not executed.

Using

-------------------BEGIN-----------
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)\.html$ /search.cgi/?keywords=$1

Options +execCGI +Includes
Options +execCGI +Includes

AddHandler server-parsed .shtml .html
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php5 .php
-------END------------

The above allows my cgi to run and get results. However, now I have not navigation showingup!

Help!

Thanks,

Ed

Apostropartheid
01-03-2009, 12:45 AM
You can't use SSI and PHP together. Just use PHP (use the include() function like you are for your navigation.)

id est use the first .htaccess and this code:

<?php include("../search.cgi/?&keywords=test+code"); ?>
<?php include($_SERVER['DOCUMENT_ROOT']."/left-navigation.php"); ?>

sgtaw
01-03-2009, 01:14 AM
You can't use SSI and PHP together. Just use PHP (use the include() function like you are for your navigation.)

id est use the first .htaccess and this code:

<?php include("../search.cgi/?&keywords=test+code"); ?>
<?php include($_SERVER['DOCUMENT_ROOT']."/left-navigation.php"); ?>


Cool! It's running :thumbsup:

Now I get this error... Any ideas?

-----------BEGIN------------
Warning: include(../search.cgi/?&keywords=test+code) [function.include]: failed to open stream: Not a directory in /user/public_html/racing/index.html on line 119
-----------END----------

When I was running the CGi as an includes, it worked fine. So. I'm baffled. Something with running php?



Thanks!

Ed

Apostropartheid
01-03-2009, 01:21 AM
I'm not sure. You could try removing the forward slash from between search.cgi and ? and the ampersand between ? and keywords (I don't see the point to the former and the latter is redundant). You could also try an absolute link (full URI address including protocol.)
e.g. include("../search.cgi?keywords=test+code");
or include("http://example.com/search.cgi/?&keywords=test+code");
or include("http://example.com/search.cgi?keywords=test+code");

sgtaw
01-03-2009, 01:42 AM
Sorry, typo on the ampersand...

These are the errors I get now...

--------BEGIN------------
Warning: include(/user/public_html/search.cgi/?&keywords=test+code) [function.include]: failed to open stream: Not a directory in /user/public_html/racing/index.html on line 121

Warning: include() [function.include]: Failed opening '/user/public_html/search.cgi/?&keywords=test+code' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /user/public_html/racing/index.html on line 121
-------END-----------------

Thanks so much for the help!

Do you have "donate" button?

thanks,

Ed

Apostropartheid
01-03-2009, 05:27 PM
Did you try the latter two examples I gave you? Replace "http://example.com" with your website.

sgtaw
01-03-2009, 05:32 PM
Did you try the latter two examples I gave you? Replace "http://example.com" with your website.

Yes I did.

The & was my mistake a typo.

The / must be there for the script to work.

Thanks,

Ed