Shadowfax has asked for the wisdom of the Perl Monks concerning the following question:

in the interest of 100% dynamic html, is there any way to cause the web server to default to executing a perl script instead of an html document? i know you could simply have a file with an EQUIV tag send it to the script auto- refresh style, but that is a cheap work-around. that question asked... if it is possible, then will a search engine execute the script and see the meta tags or will the site then be invisible to such web crawlers?

thanx in advance.

"A computer is almost human -
except that it does not blame
its mistakes on another computer."

Edit: chipmunk 2001-05-09

Replies are listed 'Best First'.
Re: defaulting to a perl script...
by rchiav (Deacon) on May 10, 2001 at 00:56 UTC
    How you do this is going to be dependant on your web server. For example, on Apache, you're first going to have to install mod_perl and then do edit your httpd.conf to create another default document. But before you do that, you're going to have to allow script execution outside of the cgi-bin dir (or at least that's what I do)..

    here's what's in my httpd.conf for that (you should read the mod_perl documentation so you REALLY know what's going on though.)

    <Files *.pl> SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI </Files>
    You could also restrict this to just a directory if you wanted. -
    <Location /perl> SetHandler perl-script PerlHandler Apache::Registry Options +ExecCGI </Location>
    As far as adding a default page, look for DirectoryIndex..
    DirectoryIndex index.html index.htm index.shtml index.php index.php4 i +ndex.php3 index.cgi index.pl
    And I belive that a spider will request the default page from the root of your site. If that happens to be a script, it will get the results of the script.

    Hope this helps..
    Rich

(Ovid - OT) Re: defaulting to a perl script...
by Ovid (Cardinal) on May 10, 2001 at 00:48 UTC

    This is not really a Perl question, but a Web server question. How to set this up depends upon the Web server you use.

    In a recent post, $code or die explained to set this up with IIS.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

      And under Apache, I believe it is ...

        Options +ExecCGI
        DefaultType application/x-httpd-cgi

      (Although that makes the default document type a CGI, which can -- of course -- be a Perl script.)

          --k.


Re: defaulting to a perl script...
by cLive ;-) (Prior) on May 10, 2001 at 00:54 UTC
    If you're talking about default file to return when a domain/directory url is entered... if using apache, you need to amend DirectoryIndex in your httpd.conf or, if allowed, I think adding it to your .htaccess file for the particular directory also does the trick.

    If you're using another server - sorry, no idea...

    cLive ;-)

Re: defaulting to a perl script: some dirty solutions
by thpfft (Chaplain) on May 10, 2001 at 03:32 UTC

    There are two simple ways to do this, both of which are probably deplorable to people who know how to work apache properly, but i use them all the time. As far as I know both will allow the spidering of at least that page: if your onward links involve cgi-bins and query strings then those might not.

    The global server configuration will quite often include index.cgi towards the end of the DirectoryIndex line, in which case all you have to do is make sure that a file with that name is the only index in your directory. Well, probably not all: you may have to create the .htaccess file that allows ExecCGI in that directory, and so on: that's all described by other people here. You shouldn't need to change the default type, though, and it means that you can link to directory/ and people don't see the cgi part at all.

    Obviously, you also have to make sure that both the cgi and the directory are chmod 755. i only mention it because i spent several hours last night debugging scripts that were in a directory without +x (funny how you can always find bugs, though.)

    The other possibility is even more low-tech, and only really useful on a very restricted server. If you can't do anything else, create an index.shtml file containing only an SSI tag to invoke the script you want, with query string in the usual way. You can do that with either <!--#include virtual="..."--> or <!--#exec cgi="..."--> according to taste. The main problem is that you sacrifice control of the headers, to the extent that you often can't even set a cookie. It's also rather inefficient, but it is a nice, quick and dirty way of putting a straight face on a cgi, and it's not hard to read parameters from the address of the calling page if you need to.

    If you can't even get SSI then it's the wrong server.

    I realise these are not the elegant solutions you were looking for, but i hope it's useful all the same.