drupal 做301跳转(删除url里的www), 关键代码 可用到任何网站

//hook_init();
function ex_init(){
	//删除 url 前面的 www
	if (substr($_SERVER['HTTP_HOST'],0,3) == 'www'){
		header('Location:http://'.substr($_SERVER['HTTP_HOST'], 4).$_SERVER['REQUEST_URI'], true, 301);
	}
}



原文地址:https://www.cnblogs.com/james1207/p/3423898.html