如何從一個(gè)域名跳轉(zhuǎn)到另一個(gè)域名?從域名跳轉(zhuǎn)到另一個(gè)域名,其實(shí)可以做301重定向。不同的服務(wù)器、不同的環(huán)境和語(yǔ)言、不同的方法,我們簡(jiǎn)要介紹兩種方式。
許多企業(yè)為了保護(hù)自己的品牌,會(huì)申請(qǐng)多個(gè)域名,如com、cn、net、info等。此時(shí),如果希望每個(gè)域名在訪問(wèn)時(shí)自動(dòng)跳轉(zhuǎn)到com,如何實(shí)現(xiàn)?
域名準(zhǔn)備:web1.com,web2.cn,web3.net,web4.info
1,Apache服務(wù)器
首先將域名解析為服務(wù)器ip:1.1.1
然后添加
將.net設(shè)置為.com服務(wù)器名web3.netserveralias www.web3.netredirectmatch permanent^/(。*)http://web1.com/$1#set.cn to.comservername web2.cnserveralias www.web2.cnredirectmatch permanent^/(。*)http.conf/virtualhost>將.info設(shè)置為.com服務(wù)器名web4.infoserveralias www.web4.inforedirectmatch permanent^/(。*)http://web1.com/$1serveradmin xxxx@web1.comservername web1.comserveralias www.web1.com
然后重新啟動(dòng)apache服務(wù)器
2,.htaccess mode
在虛擬主機(jī)中,有l(wèi)inux、windows和其他操作系統(tǒng)。以更常見的linux為例,我們使用.htaccess文件實(shí)現(xiàn)301重定向:
rewriteengine onrewritecond%{http_host}^web2.cn[nc,or]rewritecond%{http_host}^web3.net[nc,or]rewritecond%{http_host}^web4.info[nc,or]rewritecond%{http_host}^web1.com$[nc]rewriterule^(。*)$http://www.web1.com/$1[l,宗教301]
這里。cn、net或info自動(dòng)跳轉(zhuǎn)到web1,web1.com自動(dòng)跳轉(zhuǎn)到www.web1.com。
以上是關(guān)于“如何跳轉(zhuǎn)到另一個(gè)域名”的相關(guān)文章介紹。如果您需要注冊(cè)域名,或者對(duì)于技術(shù)有什么好感,建議您訪問(wèn)http://m.y447.cn/reg.htm。