Some common instruction _php skills based on header

Source: Internet
Author: User
Tags http authentication 503 service temporarily unavailable

Header Common Instructions
The header is divided into three parts:
The first part is the HTTP protocol version (http-version);
The second part is state code (status);
The third part is the causal phrase (reason-phrase).

Fix 404 Pages: Use this header directive to resolve the 404 header generated by the URL rewrite
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 moved Permanently ');

Access restricted
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 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 modification time (available at cache time)
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 yet 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 (available when caching):
Set content Length (good for caching):
Header (' content-length:1234 ');

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

//Prohibit caching of current documents:
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, June 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 the 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'll 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 no resource response found
Header (' http/1.1 404 Not Found ');

Send a 301 Permanent redirect
Header (' http/1.1 moved Permanently ');

Send a 503 Web site temporarily unable to access
Header (' http/1.1 503 Service temporarily unavailable ');

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

Set Page 3 seconds to redirect
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 Web page output a PDF document
Header (' content-type:application/pdf ');

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

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.