Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    CGI and SSI together?

    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

  • #2
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    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 Code:
    <?php include("../search.cgi/?&keywords=test+code"); ?>
    <?php 
    include($_SERVER['DOCUMENT_ROOT']."/left-navigation.php"); ?>

  • Users who have thanked Apostropartheid for this post:

    sgtaw (01-03-2009)

  • #3
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by CyanLight View Post
    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 Code:
    <?php include("../search.cgi/?&keywords=test+code"); ?>
    <?php 
    include($_SERVER['DOCUMENT_ROOT']."/left-navigation.php"); ?>
    Cool! It's running

    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

  • #4
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    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");
    Last edited by Apostropartheid; 01-03-2009 at 02:23 AM.

  • #5
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #6
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    Did you try the latter two examples I gave you? Replace "http://example.com" with your website.

  • #7
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by CyanLight View Post
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •