Forum Moderators: coopster & phranque

Message Too Old, No Replies

How to diplay .cgi script results as html pages

cgi to html

         

interbuy

10:30 pm on Mar 30, 2004 (gmt 0)

10+ Year Member



I would like to have our cgi script output html pages as this website does.

As an example [test.com...]

Have it output [test.com...]

I wonder if mod_rewrite can make a global change and pick up the query?

Thanks for any assistance

tombola

9:10 am on Mar 31, 2004 (gmt 0)

10+ Year Member



Welcome to WebmasterWorld, interbuy!

This topic has been discussed in another recent thread:
[webmasterworld.com...]

Hissingsid

9:48 pm on Mar 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

Put this in your root .htaccess file. (This often works on 'nix servers running Apache but only if your web host admin allows it in their httpd.conf file.)

<FilesMatch "^search$">

ForceType application/x-httpd-cgi

</FilesMatch>

Then you need something like this in your cgi script which you call search.cgi. This reads URLs in the form [test.com...]

#!/usr/bin/perl

use CGI;

$q = new CGI;

$path = $q ->path_info();

#YOU MUST INSERT a regex test here to stop rogues sending dangerous characters into your script.

@path = split(/\//, $path);

#If you know @path always has three values in it you know that $path [2] is in this case cats and use that to match with a key in your database

Best wishes

Sid