错误重定向到特殊字符的宁静

时间:2013-11-23 10:14:22

标签: apache get url-encoding

当我使用GET方法重定向时       $ UID =用urlencode($ UID);       标题(位置:“http://www.example.com/teldom.me.jersey/index.html?userid= $ uid& lang = $ lang”);'

在tomcat中使用url编码的特殊字符进行java restful service runnig,浏览器显示:

The requested URL /teldom.me.jersey/rest/conf/EBo6Fp3Od00urp6TIF/3gGcrsg== was not found on this server

Apache错误日志

[Sat Nov 23 00:13:02 2013] [error] [client xx.yy.65.87] File does not exist: /home/bmil/Dokumenti/webapps/cdn-cgi, referer: http://www.example.com/teldom.me.jersey/index.html?userid=EBo6Fp3Od00urp6TIF%2F3gGcrsg%3D%3D

在javascript中,我使用

将ajax请求发送到restful服务
http('POST', submitTo, ajax_response, document.form1); 

这是一个用于AJAX的ColdFusion API。 (v 2.6.0)

问题是当ajax使用特殊的html chars%2F向Tomcat发送请求时

以下是来自tomcat localhost访问日志文件:

xx.yy.65.87 - - [23/Nov/2013:23:17:14 +0100] "GET /teldom.me.jersey/index.html?userid=EBo6Fp3Od00urp6TIF%2F3gGcrsg%3D%3D&lang= HTTP/1.1" 304 -

xx.yy.65.87 - - [23/Nov/2013:23:09:38 +0100] "POST /teldom.me.jersey/rest/conf/E6iKbMC8jTFz4JifHDdqogj3?nocache=1385244552675 HTTP/1.1" 200 288
8

1 个答案:

答案 0 :(得分:0)

解决!

 $find_entities = array("/","&", "?");
 if(strpos($id, $find_entities) !== false)
 {
   $uid=urlencode ($uid);
   $uid=urlencode ($uid);
 } else {
      $uid=urlencode ($uid);
 }

  header("Location: http://www.example.com/teldom.me.jersey/index.html?userid=$uid");