① 濡備綍鍋氬埌璁块棶浜岀骇鍩熷悕鎸囧悜鎴戠綉绔欐牴鐩褰曠殑浜岀骇鐩褰曞憿锛
杩欎釜鏂规硶鍊掓槸涓嶅皯锛屼笉杩囪佹牴鎹鑷宸辩殑鍏蜂綋鐜澧冨弬鑰冮夋嫨锛
鏂规硶涓锛氱敤js璺宠浆
鍦ㄧ┖闂翠笂鍒嗗埆缁戝畾www.aaa.com鍜www.bbb.com
鎶www.aaa.com缃戠珯鏂囦欢浼犲埌鏍圭洰褰曪紝鎶www.bbb.com缃戠珯浼犲埌./bbb/鐩褰
鎶婁笅闈㈢殑浠g爜淇濆瓨涓篸omain.js锛岀劧鍚庝笂浼犲埌绌洪棿鏍圭洰褰
JavaScript浠g爜
switch(location.host){
case'www.bbb.com':
location.href="http://www.boaer.com/bbb/"
break;
}
寰绌洪棿鏍圭洰褰曠殑棣栭〉鐨<head>涓</head>涔嬮棿鍔犲叆<scriptlanguage='javascript'src="/bbb/domain.js"></script>褰撹緭鍏www.aaa.com璁块棶鏃剁湅涓嶅埌浠讳綍鍙樺寲锛屼絾鏄褰撹緭鍏www.bbb.com璁块棶鏃讹紝娴忚堝櫒鑷鍔ㄨ烦杞鍒www.bbb.com/bbb/銆
瑕佸疄鐜板氫釜缃戠珯鍙浠ヤ緷姝ょ被鎺ㄣ傛垨鑰呯洿鎺ュ湪澶撮儴娣诲姞绫讳技濡備笅浠g爜锛
<scriptlanguage=javascript>
if(document.domain=='www.boaer.com')
this.location="www.bbb.com"+this.location.pathname+this.location.search;
</script>
鏂规硶浜岋細锛堟帹鑽愶級
鐢╯erver.Transfer("")鏉ュ疄鐜颁竴涓绌洪棿澶氫釜绔欑殑鏂规硶
鍏堝皢鎵鏈夌殑鍩熷悕缁戝畾鍒版偍鐨勮櫄鎷熶富鏈轰笂锛岀劧鍚庡皢铏氭嫙涓绘満鏍圭洰褰曚腑鐨刬ndex.asp锛堥栭〉鏂囦欢锛夐噷鍔犲叆涓嬪垪浠g爜灏卞彲浠ヤ簡锛欰SP/Visual Basic浠g爜
<%
sn=lcase(Request.ServerVariables("SERVER_NAME"))'鐢ㄤ簬鑾峰彇鐢ㄦ埛鏄閫氳繃鍝涓鍩熷悕璁块棶鐨勶紝骞惰浆鎹㈡垚灏忓啓
ifsn="www.abc.net"orsn="abc.net"thenserver.Transfer("default1.asp")
ifsn="www.def.net"orsn="def.net"thenserver.Transfer("index.html")
%>
鏁堟灉锛氬傛灉杈撳叆鐨勫煙鍚嶆槸www.abc.net鎴朼bc.net鐨勮瘽锛屽氨璁块棶default1.asp椤甸潰锛屽傛灉鏄鐢╠ef.net鎴www.def.net鐨勮瘽灏辫皟鐢╥ndex.html鏂囦欢銆
鏂规硶涓夛細锛堟渶鏂逛究绠$悊锛屼竴涓绌洪棿鏀剧殑绔欒秺澶氳秺鎺ㄨ崘锛
鏂规硶鏄鍒╃敤涓涓猘sp鏂囦欢閫氳繃娴忚堝櫒杈撳叆鐨勫煙鍚嶏紝鍒ゅ畾鏄瑕佹墦寮閭d釜鏂囦欢澶归噷鐨勭珯鐐癸紝鏉ュ疄鐜颁竴涓铏氭嫙鏀剧疆澶氫釜绔欑偣锛堢己鐐逛緥濡傛墦寮abc.com锛屽湪娴忚堝櫒涓鐪嬪埌鐨勬槸abc.com/b鍥犱负绔欑偣鍦╞鐩褰曚笅锛
鍏朵粬璇存槑锛氬傛灉铏氭嫙涓绘満涓嶆敮鎸佸瓙鐩褰曠粦瀹氾紝杩欐槸闈炲父鏈夋晥鐨勫姙娉曞疄鐜版柟娉曞備笅 锛氬厛寤虹珛涓涓榛樿や富椤礽ndex.asp,鎶夾绔欐斁鍦ˋ鏂囦欢澶逛笅锛孊绔欐斁鍦˙鏂囦欢澶逛笅锛孋绔欐斁鍦–鏂囦欢澶逛笅銆 index.asp缃戦〉鏂囦欢濡備笅 锛
ASP/Visual Basic浠g爜
<%ifRequest.ServerVariables("SERVER_NAME")="www.a.com"then
response.redirect"a/index.asp"
elseifRequest.ServerVariables("SERVER_NAME")="www.b.com"then
response.redirect"b/index.asp"
elseifRequest.ServerVariables("SERVER_NAME")="www.c.com"then
response.redirect"c/index.asp"
else
response.redirect"aaa/index.asp"
endif%>
浠g爜浣滅敤璇存槑锛
濡傛灉鐢ㄦ埛璁块棶www.a.com绋嬪簭璺宠浆鑷 绌洪棿鐩褰曚笅 a/index.asp
濡傛灉鐢ㄦ埛璁块棶www.b.com绋嬪簭璺宠浆鑷 绌洪棿鐩褰曚笅 b/index.asp
濡傛灉鐢ㄦ埛璁块棶www.c.com绋嬪簭璺宠浆鑷 绌洪棿鐩褰曚笅 c/index.asp
濡傛灉鐢ㄦ埛璁块棶 娌℃湁鎸囧畾鐨 绋嬪簭璺宠浆鑷 绌洪棿鐩褰曚笅 aaa/index.asp
elseif Request.ServerVariables("SERVER_NAME")="www.b.com" then
response.redirect "b/index.asp"
杩欐垫槸鍙浠ユ棤闄愬嶅埗鐨勶紝涓涓铏氭嫙涓绘満鏀惧嚑鐧句釜绔欑偣灏辨槸鑷宸辫剧疆鐨勪簡鍙瑕佹妸鍩熷悕閮界粦瀹氬湪铏氭嫙涓绘満涓婏紝鐒跺悗璁剧疆杩欎釜鍩熷悕鎵缁戝畾鐨勭珯鐐瑰氨OK浜,杩欑嶈佺湅铏氭嫙涓绘満鑳界粦澶氬皯涓鐜夌背銆傝兘缁100涓鐨勮瘽灏辫兘鏀100涓绔欙紝骞朵笖鍒╀簬缃戠珯绠$悊锛岃繖鏍峰仛鍙浠ユ牴鎹鏂囦欢澶瑰悕锛屽氨鐭ラ亾杩欎釜鏄鍝涓绔欍
PHP绌洪棿鐨勬柟娉
鍒╃敤PHP鏄鍙浠ュ疄鐜拌繖涓鍔熻兘鐨勩備笉浣嗚╀粬杩愯屽氫釜缃戠珯锛岃屼笖杩樺彲浠ュ疄鐜版瘡涓缃戠珯鐙绔嬪煙鍚嶃備笅闈㈡妸璇︾粏鐨勬ラよ存槑涓涓嬨傞栧厛浜嗚В涓涓$_SERVER['HTTP_HOST']鍙橀噺銆傝繖涓鍙橀噺鍦≒HP涓鏄鐢ㄦ潵鍙栨祻瑙堝櫒涓鎵杈撳叆鐨勫湴鍧鐨勩傚彲浠ュ疄鐜颁笂闈㈢殑鍔熻兘浜
鍏堟妸闇瑕佺殑涓や釜鍩熷悕瑙f瀽鍒扮┖闂淬傛瘮濡傦細www.***com鍜www.***.cn涓や釜鍩熷悕銆傚傛灉鏈夋洿澶氱殑鍩熷悕涔熸病鍏崇郴銆傛柟娉曟槸涓鏍风殑銆
鎶婇粯璁ゆ枃妗h剧疆涓篿ndex.php锛屽綋鐒剁┖闂撮渶瑕佹槸鏀鎸丳HP鐨勫摝銆傦細锛
3銆佸埄鐢╥f ... else 鏉ュ垽鏂鏉ヨ垮湴鍧锛屽苟浣滃嚭鍒嗘瀽銆備唬鐮佸備笅锛
<?if($_SERVER['HTTP_HOST']=="www.123.com";){?>
<META HTTP-EQUIV="Refresh" CONTENT="1;URL=http://www.123.com/main">
<?}else if($_SERVER['HTTP_HOST']=="mycalf.com"){?>
<META HTTP-EQUIV="Refresh" CONTENT="1;URL=http://123.com/main">
<?}else if($_SERVER['HTTP_HOST']=="www.456.cn";){?>
<META HTTP-EQUIV="Refresh" CONTENT="1;URL=http://www.456.cn/home">
<?}else{?>
<META HTTP-EQUIV="Refresh" CONTENT="1;URL=http://www.456cn/home">
<?}?>
4銆佸畬鎴
杩欓噷瑕佽存槑鐨勪竴鐐规槸锛屾湁鐨勬椂鍊欏煙鍚嶆槸鐢ㄥぇ鍐欑殑锛岄偅涔堝氨闇瑕佸$_SERVER['HTTP_HOST']杩欎釜鍙橀噺杩涜屽勭悊锛屾潵璁╀粬鎶婃墍鏈夌殑瀛楃﹁浆鎹㈡垚灏忓啓銆
浠g爜濡備笅锛
<?
$querystring = preg_replace(array("/()/","/_/"),array("","-"),$_SERVER["QUERY_STRING]);
$I = strtolower(trim($_SERVER['HTTP_HOST']));
?>
濡傛灉鏄杩欐牱鍐欙紝灏遍渶瑕佹妸涓婇潰鐨<?if($_SERVER['HTTP_HOST']=="www.123.com";){?>杩欏彞鍙樹负<?if($I=="www.123.com";){?>,杩欐牱灏卞彲浠ュ湪杈撳叆缃戝潃鏄澶у啓鐨勬椂鍊欙紝涔熷彲浠ユe父璁块棶浜嗐
杩欎釜鏂规硶涔熸湁涓涓涓嶈冻鐐癸紝灏辨槸闇瑕佸湪鍩熷悕鍚庨潰璺熶竴涓鐩褰曞悕銆備絾鏄濡傛灉浣犱笉鎬曚贡鐨勮瘽锛屼篃鍙浠ユ妸涓や釜缃戠珯閮芥斁鍒版牴鐩褰曚笅銆備絾鏄鎺ㄨ崘鏄姣忎釜缃戠珯涓涓鐩褰曘傜幇鍦ㄨ稿氱┖闂村晢锛岄兘鏀鎸5涓浠ュ唴鐨勫煙鍚嶇殑瑙f瀽銆傝繖鏍峰氨鍙浠ヤ拱涓涓绌洪棿锛屾嫢鏈5涓缃戠珯浜嗐
杩欎釜鍔炴硶鐨勪紭鍔夸篃鏄鏈夌殑锛屼粬姣忎釜鍩熷悕閮芥槸鍙浠ヨ块棶鍏朵粬缃戠珯鐨勶紝姣斿傝緭http://www.123.com/home/涓庤块棶http://www.123.cn/鍩熷悕寰楀埌鐨勬晥鏋滄槸涓鏍风殑銆
鍏跺疄绌洪棿楹荤儲鐨勬槸鏁版嵁搴撻棶棰橈紝涓嶈繃鏁版嵁搴撲篃鏄鍙浠ュ氫釜缃戠珯鍏变韩涓涓鏁版嵁搴撶殑锛屽彧瑕佷笉璁╄〃鍚嶄竴鏍峰氨鍙浠ヤ簡銆傝块棶璧锋潵閬撶悊宸涓嶅氥
② 璋佺煡閬123褰遍櫌鐨勭綉鍧锛
http://www.end123.com/ (瓒呯墰鍏嶈垂鐢靛奖) http://www.dy123.net/