轉載自: PHPChina
近來接受 BBT 的培訓,做一個投票系統。系統程式碼倒不是很難,但是我的時間主要花費在了研究字符集和編碼上面。MySQL 和 Apache 兩個系統的編碼(字符集)問題讓我費勁腦筋,吃盡苦頭。網上對這些問題的解決比較零散,比較片面,大部分是提供解決方法,卻不說為什麼。於是我將這幾天收穫總結一下,避免後來者再走彎路。這篇文章對 PHP 編寫有一點幫助(看完你就知道,怎樣讓你的 PHP 程式在大部分空間提供商的伺服器裡顯示正常),但是更多幫助在於網路伺服器的架設和設置。
HTML
<head>
<meta http-equiv=refresh content="0;url=http://host.domain.tld/path/to/">
</head>
JavaScript
<script language="JavaScript">
<!--
window.location.href = "http://host.domain.tld/path/to/";
//-->
</script>
PHP
<?php
header("Location: http://host.domain.tld/path/to/");
?>
(轉址前不可有任何資料輸出)
Perl
#!/usr/bin/perl -w
print "Location: http://host.domain.tld/path/to/ \n\n";
(轉址前不可有任何資料輸出)
Perl - 使用 CGI 模組
#!/usr/bin/perl -w
use CGI qw/:standard/;
my $CGI = CGI->new();
print $CGI->redirect("http://host.domain.tld/path/to/");
(轉址前不可有任何資料輸出)