in reply to 404 to Apache

If you're not running under mod_perl, then you'll need to parse your Apache's httpd.conf yourself, since server configuration information is not passed to a CGI environment. Config::ApacheFormat can probably be of use.

If you are running under mod_perl, then you can use the dir_config method on the request object to get configuration information.

Replies are listed 'Best First'.
Re^2: 404 to Apache
by artist (Parson) on Oct 27, 2006 at 17:47 UTC
    I don't need to know the location of '404 file' specified in Apache server. I might just to need to return the header as '404 not found' and let Apache server pickup from that.
    --Artist
      It doesn't appear that will happen. You can send a '404' status through the header status CGI print $q->header(-status=>404); (which works, it does send a 404 error to the browser) but Apache seems to ignore it. As one might expect, since a 404 should normally occur before the script is called.

      You'll either have the use the Apache modules or parse the config for the standard Apache (ErrorDocument 404 /missing.html) page and return that along with the header status of 404.



      grep
      One dead unjugged rabbit fish later
        Add  -nph => 1,
        From CGI.pm docs:
        print redirect(-uri=>"http://somewhere.else/in/movie/land", -nph=>1, -status=>301);
          The -status parameter will set the status of the redirect.  HTTP
               defines three different possible redirection status codes:
        
                    301 Moved Permanently
                    302 Found
                    303 See Other
         The default if not specified is 302, which means "moved temporarily."
               You may change the status to another status code if you wish.  Be
               advised that changing the status to anything other than 301, 302 or
               303 will probably break redirection.
        
        
        
        That means, I cannot return 404, if I redirect. Is there any way around?
        --Artist