yxhxj2006

          常用鏈接

          統(tǒng)計(jì)

          最新評(píng)論

          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)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 凤山县| 文山县| 合川市| 东阳市| 土默特右旗| 安龙县| 运城市| 湟源县| 高碑店市| 华容县| 中西区| 荣昌县| 平昌县| 交口县| 屏东市| 武功县| 永嘉县| 珲春市| 孟津县| 新津县| 文成县| 孟村| 从江县| 通化市| 铜川市| 临邑县| 建瓯市| 都匀市| 惠安县| 新晃| 剑河县| 太保市| 利辛县| 宝兴县| 平山县| 旅游| 许昌市| 永丰县| 忻城县| 越西县| 常德市|