输入主域名,自动跳转到www域名下。 代码如下。
$ the _ host=$ _ server [ ' http _ host ' ]; //获取当前域名$ the _ URL=isset ($ _ server [ ' request _ uri ' ] )? $_SERVER['REQUEST_URI'] : '; //判定地址后面的部分$the_URL=strtolower($the_URL ); //是否将英文字符转换为小写if ({ $the_URL=)/index.PHP )|{ $the_url=(/index.html ) ) /首页) $ the _ URL=' ) //301头部标题(location 33603358 www.* * *.com); 跳转到带有//www的URLexit; (if ) $the_host=='**.com ' ) /如果域名是没有www的网站,则进行下一个301跳转) header ) ) http/1.1301movedpermanently ); //301只头(location 33603358 www.* * *.com (.$ the _ URL ) ); 跳转到带有//www的URLexit; }