首頁 後端開發 php教程 PHP 批改HTTP头 -Modify HTTP Headers

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 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱門文章

兩個點博物館:邦格荒地地點指南
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱門文章標籤

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

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

http狀態碼520是什麼意思 http狀態碼520是什麼意思 Oct 13, 2023 pm 03:11 PM

http狀態碼520是什麼意思

瞭解網頁重定向的常見應用場景並了解HTTP301狀態碼 瞭解網頁重定向的常見應用場景並了解HTTP301狀態碼 Feb 18, 2024 pm 08:41 PM

瞭解網頁重定向的常見應用場景並了解HTTP301狀態碼

如何使用Nginx Proxy Manager實現HTTP到HTTPS的自動跳轉 如何使用Nginx Proxy Manager實現HTTP到HTTPS的自動跳轉 Sep 26, 2023 am 11:19 AM

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

Go中Type關鍵字有哪些用法 Go中Type關鍵字有哪些用法 Sep 06, 2023 am 09:58 AM

Go中Type關鍵字有哪些用法

http請求415錯誤解決方法 http請求415錯誤解決方法 Nov 14, 2023 am 10:49 AM

http請求415錯誤解決方法

解決Ubuntu掛載行動硬碟錯誤:未知的檔案系統類型exfat 解決Ubuntu掛載行動硬碟錯誤:未知的檔案系統類型exfat Jan 05, 2024 pm 01:18 PM

解決Ubuntu掛載行動硬碟錯誤:未知的檔案系統類型exfat

http狀態碼403是什麼 http狀態碼403是什麼 Oct 07, 2023 pm 02:04 PM

http狀態碼403是什麼

快速應用:PHP 非同步 HTTP 下載多個檔案的實用開發案例分析 快速應用:PHP 非同步 HTTP 下載多個檔案的實用開發案例分析 Sep 12, 2023 pm 01:15 PM

快速應用:PHP 非同步 HTTP 下載多個檔案的實用開發案例分析

See all articles