Some common instructions based on header _php tutorial

Source: Internet
Author: User
Tags http authentication 503 service temporarily unavailable
Header Common Directives
The header is divided into three parts:
The first part is the version of the HTTP Protocol (http-version);
The second part is state code (status);
The third part is the reason phrase (reason-phrase).

Fix 404 Pages: Use this header command to resolve the 404 header generated by URL rewriting
Header (' http/1.1 OK ');

Set 404 Header: Page not found
Header (' http/1.1 404 Not Found ');

Pages are permanently deleted and can tell the search engine to update their URLs
Set Moved permanently header (Good for redrictions)
Use with location header
Header (' http/1.1 301 Moved permanently ');

Restricted access
Header (' http/1.1 403 Forbidden ');

//Server error
Header (' http/1.1 Internal Server Error ');

//Redirect to a new location
Redirect to a new location:
Header (' location:http://www.example.org/');

Redirect after a period of delay
Redrict with delay:
Header (' refresh:10; url=http://www.example.org/');
print ' You'll be redirected in ten seconds ';

//Overwrite x-powered-by value
Override x-powered-by:php:
Header (' x-powered-by:php/4.4.0 ');
Header (' x-powered-by:brain/0.6b ');

//Content language (en = 中文版)
Content language (en = 中文版)
Header (' content-language:en ');

//Last modified time (can be used in cache)
Last modified (good for caching)
$time = time ()-60; or Filemtime ($FN), etc
Header (' last-modified: '. Gmdate (' d, D M Y h:i:s ', $time). ' GMT ');

//Tell the browser what to get is not updated
Header for telling the browser the content
did not get changed
Header (' http/1.1 304 not Modified ');

//Set the length of the content (can be used when caching):
Set content Length (good for caching):
Header (' content-length:1234 ');

//To download files:
Headers for an download:
Header (' Content-type:application/octet-stream ');
Header (' content-disposition:attachment; filename= ' Example.zip ');
Header (' content-transfer-encoding:binary ');

//Disable caching of the current document:
Load the file to Send:readfile (' example.zip ');
Disable caching of the current document:
Header (' Cache-control:no-cache, No-store, max-age=0, Must-revalidate ');
Header (' Expires:mon, Jul 1997 05:00:00 GMT ');

//Set Content type:
//Date in the Pastheader (' Pragma:no-cache ');
//Set Content Type:
Header (' content-type:text/html; charset=iso-8859-1 ');
Header (' content-type:text/html; Charset=utf-8 ');
Header (' Content-type:text/plain ');

//Plain text file
Header (' content-type:image/jpeg ');

//JPG picture
Header (' Content-type:application/zip ');

//ZIP file
Header (' content-type:application/pdf ');

//PDF file
Header (' content-type:audio/mpeg ');

//Audio MPEG (MP3,...) file
Header (' Content-type:application/x-shockwave-flash ');

//Display Login dialog box, which can be used for HTTP authentication
//Flash animation//show sign In box
Header (' http/1.1 401 Unauthorized ');
Header (' Www-authenticate:basic realm= ' Top Secret ');
print ' Text that would be displayed if the user hits cancel or ';

print ' enters wrong login data ';? >

Send a 200 normal response
Header ("http/1.1 OK");

Send a 404 resource response not found
Header (' http/1.1 404 Not Found ');

Send a 301 Permanent redirect
Header (' http/1.1 301 Moved permanently ');

Send a 503 site temporarily inaccessible
Header (' http/1.1 503 Service temporarily unavailable ');

Web redirection
Header (' location:http://www.jb51.net ');

Set page redirection after 3 seconds
Header (' Refresh:3; Url=http://www.jb51.net ');
Echo ' webpage will jump to Http://www.jb51.net ' in 3 seconds;

Set page encoding
Header (' content-type:text/html; Charset=utf-8 ');

Set page output a picture stream
Header (' Content-type:image/jpeg ');

Set up a Web page to output a PDF document
Header (' content-type:application/pdf ');

Set up a ZIP document for Web page output
Header (' Content-type:application/zip ');

http://www.bkjia.com/PHPjc/327430.html www.bkjia.com true http://www.bkjia.com/PHPjc/327430.html techarticle Header Common Command header is divided into three parts: the first part is the version of the HTTP Protocol (http-version), the second part is the status code (status), and the third part is the reason phrase (reason-phrase). ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.