PHP 批改HTTP头 -Modify HTTP Headers
Jun 13, 2016 pm 01:12 PM
content
example
header
http
type
PHP 修改HTTP头 --Modify HTTP Headers
Modify HTTP Headers
// See related links for more status codes // Use this header instruction to fix 404 headers // produced by url rewriting... header('HTTP/1.1 200 OK'); // Page was not found: header('HTTP/1.1 404 Not Found'); // Access forbidden: header('HTTP/1.1 403 Forbidden'); // The page moved permanently should be used for // all redrictions, because search engines know // what's going on and can easily update their urls. header('HTTP/1.1 301 Moved Permanently'); // Server error header('HTTP/1.1 500 Internal Server Error'); // Redirect to a new location: header('Location: http://www.example.org/'); // Redriect with a delay: header('Refresh: 10; url=http://www.example.org/'); print 'You will be redirected in 10 seconds'; // you can also use the HTML syntax: // <meta http-equiv="refresh" content="10;http://www.example.org/ /> // override X-Powered-By value header('X-Powered-By: PHP/4.4.0'); header('X-Powered-By: Brain/0.6b'); // content language (en = English) header('Content-language: en'); // 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'); // header for telling the browser that the content // did not get changed header('HTTP/1.1 304 Not Modified'); // set content length (good for caching): header('Content-Length: 1234'); // Headers for an download: header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="example.zip"'); header('Content-Transfer-Encoding: binary'); // 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, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('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'); // Flash animation // show sign in box header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Basic realm="Top Secret"'); print 'Text that will be displayed if the user hits cancel or '; print 'enters wrong login data';
登入後複製
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱門文章
兩個點博物館:邦格荒地地點指南
4 週前
By 尊渡假赌尊渡假赌尊渡假赌
擊敗分裂小說需要多長時間?
3 週前
By DDD
倉庫:如何復興隊友
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?
3 週前
By 王林

熱門文章
兩個點博物館:邦格荒地地點指南
4 週前
By 尊渡假赌尊渡假赌尊渡假赌
擊敗分裂小說需要多長時間?
3 週前
By DDD
倉庫:如何復興隊友
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?
3 週前
By 王林

熱門文章標籤

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

如何使用Nginx Proxy Manager實現HTTP到HTTPS的自動跳轉
