site.com/widget
to run a perl script instead of:
site.com/widget/widget.cgi
I'm on a linux/apache server with access to server side includes and .htaccess, but don't really understand .htaccess .
Is this possible to do? I'd appreciate any help.
This is what I do:
Put this in your root .htaccess file.
<FilesMatch "^widget$">
ForceType application/x-httpd-cgi
</FilesMatch>
Then you need something like this in your cgi script which you call widget.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 "string" and use that to match with a key in your database
Best wishes
Sid
Put this line in your .htaccess file:
Options ExecCGI MultiViews Put widget.cgi in the appropriate directory:
site.com/widget.cgi.
With content negotiation, you can omit the filename extension, so your URL could be:
site.com/widget