Download presentation
Presentation is loading. Please wait.
Published byHope McCormick Modified over 9 years ago
1
12 1 Redirection CGI/Perl Programming By Diane Zak
2
12 2 Objectives In this chapter, you will: Include the Location header in a script Include the Refresh header in a script
3
12 3 Introduction Documents often move on the Web from one location to another –Link to new URL so user must click to go to new location –Automatically forward the browser to a new address Immediately After a period of time (seconds) –META tag – HTML –Location Header – script –Refresh Header - script
4
12 4 Redirecting a browser Location header: –Immediately redirects the browser –Syntax: print “Location: url\n\n”; –Example: print “Location: http://www.rsp.com/public_html/chap12/error.html\n\n”; The 1 st newline character identifies the end of the Location header The 2 nd newline character inserts a blank line below the header to signal end of header section Location header used instead of Content-type header
5
12 5 Redirecting a Browser Refresh header: –Waits a specified number of seconds before redirection –Syntax: print “Refresh: seconds; URL=url\n”; –Example: print “Refresh: 3; URL=“http://www.rsp.com/public_html/chap12/error.html\n”; print “Content-type: text/html\n\n”; Contains one newline character because it is used with the Content-type header
6
12 6 Using a Refresh Header
7
12 7 Using a Refresh Header Uses Refresh header to redirect the page in 3 seconds
8
12 8 Using a Location Header
9
12 9 Using a Location Header If no Name was typed into the cara1.html page
10
12 10 Summary You can use the Location header or the Refresh header in a CGI script to redirect the user’s browser to another location. The Location header redirects the browser immediately. –Syntax: print “Location: url\n\n”; The Refresh header waits for a specified number of seconds until redirection. –Syntax: print “Refresh: seconds; URL=url\n”; –Is used together with the Content-type header
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.