① 濡備綍鍋氬埌璁塊棶浜岀駭鍩熷悕鎸囧悜鎴戠綉絝欐牴鐩褰曠殑浜岀駭鐩褰曞憿錛
榪欎釜鏂規硶鍊掓槸涓嶅皯錛屼笉榪囪佹牴鎹鑷宸辯殑鍏蜂綋鐜澧冨弬鑰冮夋嫨錛
鏂規硶涓錛氱敤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/