301跳轉(zhuǎn)詳細(xì)說(shuō)明
說(shuō)明:A網(wǎng)站--->B網(wǎng)站--->C網(wǎng)站--->D網(wǎng)站,其中A為提交網(wǎng)站,可以通過(guò)get或者post表單傳值,然后在B網(wǎng)站做301跳轉(zhuǎn),跳轉(zhuǎn)到C網(wǎng)站。然后在從C網(wǎng)站跳轉(zhuǎn)到網(wǎng)關(guān)D。
具體代碼實(shí)現(xiàn)步驟如下:
(1):A網(wǎng)站:只是一個(gè)簡(jiǎn)單的form表單提交:
<form action=" <input type="hidden" value="abc" name="param">
<input type="submit"/>
</form>
(2):B網(wǎng)站:首先在B網(wǎng)站目錄中寫(xiě)一個(gè)重寫(xiě)文件.htaccess。具體如下:
RewriteEngine On //開(kāi)始重寫(xiě)引擎
// .htaccess放到B網(wǎng)站/test2/目錄下,表示該301跳轉(zhuǎn)只在/test2/起作用,其他的目錄則不起作用。
RewriteBase /test2/
// http://192.168.5.17:8090/test2/index.php 為B網(wǎng)站目錄地址
RewriteCond %{HTTP_HOST} !http://192.168.5.17:8090/test2/index.php [NC]
// http://192.168.5.17:8080/servlet01/dispatcher.jsp 為C網(wǎng)站地址
RewriteRule ^(.*)$ http://192.168.5.17:8080/servlet01/dispatcher.jsp [L,R=301]
(3):C網(wǎng)站:首先獲取A網(wǎng)站提交的參數(shù):
String param = request.getParameter("param");
然后再組裝form表單:
<form action=" <input type="hidden" value="<%=param %>" name="TradeInfo">
<input type="submit"/>
</form>
(4): D網(wǎng)站:獲取從C網(wǎng)站提交過(guò)來(lái)的參數(shù)。
重點(diǎn):做了301跳轉(zhuǎn)后,從C網(wǎng)站中可以獲取到A提交過(guò)來(lái)的參數(shù),而且C網(wǎng)站獲取的來(lái)源網(wǎng)站居然是A網(wǎng)站,而不是B網(wǎng)站地址。經(jīng)過(guò)測(cè)試發(fā)現(xiàn):在B網(wǎng)站301跳轉(zhuǎn)時(shí),已經(jīng)把從A網(wǎng)站提交的參數(shù),組裝成get方式提交方式(而不管你在A采用的是post還是get提交方式),
即:<a href="> 然后會(huì)自動(dòng)跳轉(zhuǎn)到C網(wǎng)站。
posted on 2012-08-03 18:17 奮斗成就男人 閱讀(642) 評(píng)論(0) 編輯 收藏