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

I am building small company websites and I need to include a small CMS tool so that my clients can update their websites. I use Perl (CGI::Application, HTML::Template, etc.) to generate my pages. I have one index.cgi file that is called upon, I call one main.thtml template and within that file I substitute between several sub.thtml templates. Straightforward..., but, the CMS tools don't like this aproach at all. They want my index.cgi file to be an old fashioned .html file. On my webserver I have permission to have .cgi files whereever I want, but what if I wasn't? What if I had to have my .cgi files inside the cgi-bin?

Basically, I just want to know the best approach to deal with this.

Replies are listed 'Best First'.
Re: index.cgi or index.html
by zentara (Cardinal) on Aug 27, 2005 at 11:21 UTC
    It sounds to me like the apache configuration is not set. In the apache configuration file, you should have something like:
    # DirectoryIndex: Name of the file or files to use as a pre-written HT +ML # directory index. Separate multiple entries with spaces. # <IfModule mod_dir.c> DirectoryIndex index.html index.htm index.cgi index.php </IfModule>

    If the web sysadmin won't change it, then you MAY be able to set the index.cgi on a "per directory basis" with an .htaccess file. I have never tried it, Sample .htaccess file:

    <Directory "local directory"> DirectoryIndex index.cgi </Directory>

    I'm not really a human, but I play one on earth. flash japh

      Hi,

      As far as I know, you can't have a <Directory> tag inside a .htaccess.

      In httpd.conf:

      <Directory path> DirectoryIndex index.cgi </Directory>

      In .htaccess:

      DirectoryIndex index.cgi

      Update: you can read more here.

      Regards,

      |fire| at irc.freenode.net
Re: index.cgi or index.html
by fmerges (Chaplain) on Aug 27, 2005 at 10:15 UTC

    Hi,

    Don't understand well your problem... I read it 2 times... but I still not clear what you want...

    What's wrong with having a index.whatelse? You say in the webserver configuration how he should threat the different sections/locations of your website...

    If your 'websettings' are that you only can have something executable in a cgi-bin dir, then you must life with it, but that's not a problem you can have then your stuff moved into the cgi-bin dir...

    Normally you find hosting companies which give you the typical LAMP solution... and says someting like: "also CGIs" and here what you normally get is a webserver configuration where you have support to the P from LAMP associated with PHP and a cgi-bin dir where you can put a Perl CGI or whatever... Avoid this kind of hostings if you want to develop Perl web-solutions.

    And if you give more details, could be that we could help you more, because I think that others may have the same "understanding" problem as me.

    Regards,

    |fire| at irc.freenode.net
Re: index.cgi or index.html
by holli (Abbot) on Aug 27, 2005 at 11:58 UTC
    the CMS tools don't like this aproach at all
    Are you saying that you cannot use a "index.cgi" because the CMS tool is to stupid to access it? Then you could write a simple "index.html" that does nothing but using Server Side Includes (SSI) to call your "index.cgi" from wherever it may be.


    holli, /regexed monk/
Re: index.cgi or index.html
by bradcathey (Prior) on Aug 27, 2005 at 11:53 UTC

    I agree with both fmerges—confusing question (why did this get front-paged?); and zentara—something ain't right with the setup if we *are* understanding the question. Anyway, here's another example of the hidden .htaccess file that will fire up any executable in any directory:

    Options +ExecCGI SetHandler cgi-script

    This will actually run a Perl file without the .pl or .px extensions in a non-cgi-bin directory. For example, your URL could read: http://www.domain.com/foo/bar?pg=1. I use this setup for running a CMS that I install for client sites that keeps my scripts separate from other scripts that my client installs, most commoningly in the usually-present cgi-bin.


    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
Re: index.cgi or index.html
by eXile (Priest) on Aug 27, 2005 at 13:14 UTC
    Not sure what the problem is either, but if you want a plain-old index.html in your webservers document-root and use a .cgi at the same time to do all your processing, you could use a very simple index.html that redirects to your .cgi. Something like this:
     <html>
      <head>
       <meta http-equiv="Refresh" content="0;http://www.example.com/cgi-bin/your-script-here.cgi" />
      </head>
     </html>
    
    
Re: index.cgi or index.html
by punkish (Priest) on Aug 27, 2005 at 20:35 UTC
    The question is unclear, as other monks have noted. Let me have a crack at it. I believe you are lumping many different issues (questions) in one.

    Issue 1: What if my webserver doesn't allow me to keep .cgi files wherever I want, but restricts it to cgi-bin?

    Solution: In your web-server, turn on ExecCGI for the director(y|ies) where you want to keep your cgi files. In Apache, this would mean turning on ExecCGI in the httpd.conf. In IIS, you would use its management console.

    Issue 2: Your CMS doesn't like you generating templates with perl (I can't really interpret your question any other way). It wants old fashioned html. Fair enough. Well, then give it old fashioned html. Of course, how on earth (and what on earth) does your CMS then generate if gets old fashioned html to begin with? The whole point of a CMS is to generate old fashioned html, not to give it old fashioned html.

    Solution: perhaps you are referring to the extension, and not the type of file. Well, use mod_rewrite or something equivalent to change your file extensions. Or simply use different kinds of extensions (I believe HTML::Template doesn't care, however, other programs might get confused).

    --

    when small people start casting long shadows, it is time to go to bed
Re: index.cgi or index.html
by ercparker (Hermit) on Aug 27, 2005 at 18:56 UTC
    I agree with itub. If you are using apache and it was compiled with the mod_rewrite module, a rule such as this in an .htaccess file would allow it to appear you're browsing to the index.html but you would actually be at the cgi file.
    RewriteRule ^index\.html$ /cgi-bin/index.cgi [L]
Re: index.cgi or index.html
by itub (Priest) on Aug 27, 2005 at 15:09 UTC
    If you are using Apache, sometimes you can do magic with mod_rewrite.
Re: index.cgi or index.html
by johnnywang (Priest) on Aug 28, 2005 at 05:03 UTC
    Just as others, not exactly sure what you want. Assuming all you want is that something called "/index.html" to actually call "/index.cgi" (I'm guessing may be your CMS is explicitly linked to index.html?), it's rather hard to do in standard cgi, but if you use mod_perl, then it's pretty easy to add something like:
    <LocationMatch "index.html"> SetHandler perl-script PerlHandler YourIndexModule </LocationMatch>