【发布时间】:2012-03-14 12:46:39
【问题描述】:
我正在寻找正确的位置(区域)来放置我的代码 sn-p 以从 URL 中删除 WWW
该站点位于 Kohana 中,为删除“www”而编写的代码是:
$host_name = $_SERVER['HTTP_HOST']; // it stores the host name / domain name
$tmp_host = substr($host_name, 0, 3);
if($tmp_host == 'www')
{
$host_name = substr($host_name, 4);
}
任何帮助将不胜感激
【问题讨论】:
-
那根本不属于 PHP。 .htaccess 是要走的路
-
或者在它到达网站之前在你的路由器中完成它。
标签: php web url-rewriting kohana