perldoc > CGI::Application::Plugin::Redirect

📘 NAME

CGI::Application::Plugin::Redirect - Easy external redirects in CGI::Application

🚀 Quick Reference

Use CaseCommandDescription
🔄 External redirectreturn $self->redirect('http://example.com/');Redirect to an external URL
đŸ”ĸ Redirect with custom statusreturn $self->redirect('http://example.com/', '301 Moved Permanently');Redirect with a specific HTTP status code
âšī¸ Short-circuit prerunreturn $self->redirect('login.html');Interrupt current request and redirect (e.g., authentication check)
đŸ“Ļ Load pluginuse CGI::Application::Plugin::Redirect;Enable the redirect method in your CGI::Application module

📋 SYNOPSIS

package My::App;

use CGI::Application::Plugin::Redirect;

sub cgiapp_prerun {
    my $self = shift;

    if ( << not logged in >> ) {
        return $self->redirect('login.html');
    }
}

sub byebye {
    my $self = shift;

    return $self->redirect('http://www.example.com/', '301 Moved Permanently');
}

📖 DESCRIPTION

This plugin provides an easy way to do external redirects in CGI::Application. You don't have to worry about setting headers or worrying about return types, as that is all handled for you.

"redirect" does an external redirect, which means that the browser will receive a command to load a new page, and a fresh request will come in. If you just want to display the results of another runmode within the same module, then it is often sufficient to use the "forward" method in CGI::Application::Plugin::Forward instead.

🔧 METHODS

🔧 redirect($url, $status)

Interrupt the current request, and redirect to an external URL. If you happen to be inside a prerun method when you call this, the current runmode will automatically be short circuited so that it will not execute. As soon as all prerun methods have finished, the redirect will happen without the runmode being executed.

The $status parameter is optional as the CGI module will default to something suitable.

return $self->redirect('http://www.example.com/');

  - or -

return $self->redirect('http://www.example.com/', '301 Moved Permanently');

📚 SEE ALSO

👤 AUTHOR

Cees Hek <ceeshek AT gmail.com>

📄 LICENCE AND COPYRIGHT

Copyright (c) 2005, Cees Hek. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

âš ī¸ DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

CGI::Application::Plugin::Redirect
📘 NAME 🚀 Quick Reference 📋 SYNOPSIS 📖 DESCRIPTION 🔧 METHODS
🔧 redirect($url, $status)
📚 SEE ALSO 👤 AUTHOR 📄 LICENCE AND COPYRIGHT âš ī¸ DISCLAIMER OF WARRANTY

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-04 23:29 @216.73.216.89
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format