yxhxj2006

常用链接

统计

最新评论

301跳转详细说明

    
    说明:A网站--->B网站--->C网站--->D网站,其中A为提交网站,可以通过get或者post表单传值,然后在B网站做301跳转,跳转到C网站。然后在从C网站跳转到网关D。

    具体代码实现步骤如下:
   (1):A网站:只是一个简单的form表单提交:
        <form action="B网站地址" id="pay" mothod="post">
            <input type="hidden" value="abc" name="param">
            <input type="submit"/>
       </form>

  (2):B网站:首先在B网站目录中写一个重写文件.htaccess。具体如下:
            RewriteEngine On         //开始重写引擎
            // .htaccess放到B网站/test2/目录下,表示该301跳转只在/test2/起作用,其他的目录则不起作用。
            RewriteBase /test2/                         
            // http://192.168.5.17:8090/test2/index.php 为B网站目录地址
            RewriteCond %{HTTP_HOST} !http://192.168.5.17:8090/test2/index.php [NC] 
            // http://192.168.5.17:8080/servlet01/dispatcher.jsp 为C网站地址
            RewriteRule ^(.*)$ http://192.168.5.17:8080/servlet01/dispatcher.jsp [L,R=301]      
  
  (3):C网站:首先获取A网站提交的参数:
            String param = request.getParameter("param");
            然后再组装form表单:
                <form action="D网站地址" id="pay" mothod="post">
                     <input type="hidden" value="<%=param %>" name="TradeInfo">
                     <input type="submit"/>
                </form>
    (4): D网站:获取从C网站提交过来的参数。

    重点:做了301跳转后,从C网站中可以获取到A提交过来的参数,而且C网站获取的来源网站居然是A网站,而不是B网站地址。经过测试发现:在B网站301跳转时,已经把从A网站提交的参数,组装成get方式提交方式(而不管你在A采用的是post还是get提交方式),
即:<a href="http://192.168.5.17:8080/servlet01/dispatcher.jsp?param=123456789">here</a> 然后会自动跳转到C网站。


         

posted on 2012-08-03 18:17 奋斗成就男人 阅读(627) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: