即使在 url 我写“www.”,$_SERVER['HTTP_HOST'] 也只有 domain.com 没有“www.”
因此,我无法从非 www 重定向到 www。如何解决这个问题?
["HTTP_HOST"]=>
string(8) "ca-fi.ru"
["HTTP_COOKIE"]=>
string(120) "d7b6b86aae18e551749a9da9d54f3daf=floar2lr37318dc76ask49bii5; 849c6485c12558d081c065b4d94a566b=d9iqj8s6oqo41kipg3qaefq497"
["HTTP_USER_AGENT"]=>
string(99) "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5"
["PATH"]=>
string(28) "/usr/local/bin:/usr/bin:/bin"
["SERVER_SIGNATURE"]=>
string(69) "
Apache/2.2.20 (Ubuntu) Server at ca-fi.ru Port 80
"
["SERVER_SOFTWARE"]=>
string(22) "Apache/2.2.20 (Ubuntu)"
["SERVER_NAME"]=>
string(8) "ca-fi.ru"
["SERVER_ADDR"]=>
string(13) "192.168.10.12"
["SERVER_PORT"]=>
string(2) "80"
["REMOTE_ADDR"]=>
string(12) "192.168.10.1"
["DOCUMENT_ROOT"]=>
string(8) "/var/www"
["REQUEST_METHOD"]=>
string(3) "GET"
["REQUEST_URI"]=>
string(1) "/"
["SCRIPT_NAME"]=>
string(10) "/index.php"
["PHP_SELF"]=>
string(10) "/index.php"
["REQUEST_TIME"]=>
int(1338819407)