![]() |
Web Conference 2004Writing Perl/CGI Scripts for ITS/ASET Web servicesHTTP Redirects |
| <- Back - Web Access Control | | | Up | | | Advanced Techniques - Next -> |
Many Web authors are familiar with the HTML meta tag method of redirection. This is passing a tag in the HTML <head> section that instructs the browser to refresh to another page (or the same) after a set delay in seconds. An example is below which redirects the page to http://test.scripts.psu.edu/users/x/y/xyz123/scripts/newscript.cgi after a 10 second delay (set to 0 for an immediate refresh):
<meta http-equiv="Refresh" content="10; url=http://test.scripts.psu.edu/users/x/y/xyz123/scripts/newscript.cgi">
HTTP Redirects can be set by the Apache configuration, or from a CGI script, as it set in the HTTP headers. Here are examples using .htaccess and Perl methods of redirecting to the same URL as above:
| .htaccess redirect | |||
|---|---|---|---|
Redirect /users/x/y/xyz123/scripts/oldfile.html http://test.scripts.psu.edu/users/x/y/xyz123/scripts/newscript.cgi | |||
| Perl redirect | |||
#!/usr/local/bin/perl print "Location: http://test.scripts.psu.edu/users/x/y/xyz123/scripts/newscript.cgi\n\n"; |
| <- Back - Web Access Control | | | Up | | | Advanced Techniques - Next -> |
If you have any questions, feel free to ask me - mailto:jcd@psu.edu
Content by: Jeff D'Angelo <jcd@psu.edu> © 2004
Last update on: Sunday, 13-Jun-2004 23:52:02 EDT