Location Header CGI

Domain Hosting image
Web Hosting
Dedicated server
ssl certificate
Web Design image
Email

Your CGI programs can deliver an existing file from your file system or from another Web server by using the Location header. To use it, you specify either a file location relative to the root of your Web directory tree or a URL. Location : absoluteURL For example, suppose you want the CGI program to return the hello.html document. #!/usr/local/bin/perl print "Location: /hello.html\n\n";

When the browser requests one of these index.cgi programs, the server will return the same headers and the body as it does when the browser requets the hello.html file directly, something that looks like the following:

Note that the Location header is nowhere in sight. When the CG I program sends a Location header followed by a file location, the server retrieves and returns ' file as if that were the original request from the start. You could simply have your CGI program output this message using several print messages. However because the message is static, you could also save this message in an HTML and call it from your CGI program using the Location header. This way, if,, want to modify the message in any way, you edit the HTML file rather than CGI code.

You can redirect a Web browser to another Web site using a Location header followed by a URL. Other useful HTTP status codes to know for CGI programming are listed below in the table. In order to set the status code of the server responsible from your CGI program, use the Status header followed by the status code an optional status message. For example, to send a status code of 204, print the following line:

Status : 204 No Content
The server will translate this CGI header into the equivalent HTTP server response:
HTTP/1.0 204 No Content



Domain Name Search

www.


Copyright (C) 2007. Web Domain design hosting. All rights reserved.