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

Hello Monks,

Ok, i'm sure i'm just having a brain fart OR its simply not possible to do what i'm trying. The redirect simply doesn't happen with either IE9, Google Chrome or FireFox. So I suspect its a limitation that a page can't redirect?

I'm trying to redirect to index.shtml if the user requests the welcome page without being authorized first. The same redirect method works when delivered from a perl script directly

My welcomeV01.pl simply contains this:

my $URL = "http://localhost/index.shtml"; print "Status: 302 Found\n"; print "Location: $URL\n\n"; exit;

My welcome.shtml page simply contains this:

<!--#include virtual="/cgi-bin/welcomeV01.pl"-->

Thank-you kindly in advance :) *bow*

(Apache server, no errors in logs, perl is functional as i'm using it for other scripts on the same server)

SOLUTION: After a couple hours of searching google for more info on methods of accomplishing this, the idea popped into my head to use .htaccess ModRewrite to redirect all calls to welcome.shtml, directly to the welcome.pl script instead. It is working thus far, allowing me to supply content based on the client being authorized

Necessary .htaccess file changes: RewriteEngine on RewriteRule welcome.shtml /cgi-bin/welcomeV01.pl [L] Perl file code: my $URL = "http://localhost/index.shtml"; print "Status: 302 Found\n"; print "Location: $URL\r\n\r\n"; exit;

Thank-you very much for your help Monks, asking the questions here allowed me to break my thought cycle and move forward

There isn't in existence

Replies are listed 'Best First'.
Re: HTTP Redirect from SHTML page
by Anonymous Monk on Oct 24, 2011 at 06:27 UTC

    ...

    IIRC you can't use SSI to set headers, server side include don't work like that

    RTM

      I suspect the same, but couldn't find an answer either way after 4 hours of googling. Thanks for the reply :)
      There isn't in existence
Re: HTTP Redirect from SHTML page
by Anonymous Monk on Oct 24, 2011 at 06:02 UTC
    It might require the network line-ending. Try substituting "\r\n" for each "\n".

      Thank-you, i'd previously tried that unknowingly. I tried it again just now, with no change. I just end up with an empty welcome.shtml and no errors or redirect

      There isn't in existence