Lucee URI编码的问题(西里尔文) [英] Lucee URI encoding issue (cyrillic)

查看:140
本文介绍了Lucee URI编码的问题(西里尔文)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚搬到从Windows + IIS + ColdFusion的核心应用程序到Ubuntu + APACHE + Lucee之一。第一个大问题是URI编码异国字母。

例如,试图达到这个网址http://www.example.com/ru/Солнцезащитные-очки/saint-laurent/在此记录结果阿帕奇access.log的:

<$p$p><$c$c>http://www.example.com/ru/%D0%A1%D0%BE%D0%BB%D0%BD%D1%86%D0%B5%D0%B7%D0%B0%D1%89%D0%B8%D1%82%D0%BD%D1%8B%D0%B5-%D0%BE%D1%87%D0%BA%D0%B8/saint-laurent/

嗯,我认为这是正确的url-CN codeD。然后,我使用.htaccess文件重写规则来获得在URL查询字符串参数的URL(西里尔一个)的那部分(比方说富)。

使用cflog倾倒,我看到在应用程序日志中:

 /index.cfm?foo=оÑки-Ð'лN-D·ÑÐμниÑ&安培;

...这显然是错误的,因为我需要的是原始的字符串,以UTF-8西里尔。

我试图把的URIEncoding参数在我的server.xml tomcat的HTTP连接器,但没有任何结果:

 &LT;连接器端口=8888协议=HTTP / 1.1
               connectionTimeout =20000
               redirectPort =8443
                的URIEncoding =UTF-8/&GT;

我怎样才能让我的URL参数以UTF-8?


解决方案

我发现我自己的解决方案。

来源: http://blogs.warwick.ac.uk/kieranshaw/进入/ UTF-8_internationalisation_with


  

阿帕奇


  
  

通常你不必担心Apache作为它不应该是
  与你的HMTL或URL搞乱。但是,如果你正在做一些
  代理与mod_proxy的,那么你可能需要有一个思考一下
  这个。我们使用的mod_proxy通过到Tomcat做Apache的代理。
  如果你有恩,你需要转换成URL codeD字符
  为你的潜在应用中的一些查询字符串那么你将有一个
  奇怪的小问题。


  
  

如果您有进入Apache的一个URL,如下所示:


  
  

HTTP://mydomain/%E4%B8%AD.doc ,你有一个mod_rewrite的/代理规则
  像这样的:


  
  

重写规则^ /(。*)的http:// MYDOMAIN:8080 / filedownload /文件名= $ 1
  [QSA,L,P]


  
  

不幸的是,$ 1将重写期间获得错位。 QSA
  (QueryStringAppend)实际上这些字符就好及优惠
  将通过原封不动发送此,但当你抢位的URL
  比如我在这里的$ 1,则该字符获得损毁,Apache的尝试
  做一些自己的转义成ISO-8859-1,但它是UTF-8不
  ISO-8859-1,因此不能正常工作。因此,要保持我们的特殊
  在UTF-8字符,我们会再次逃脱了回去。


  
  

RewriteMap指令逃逸INT:逃跑的RewriteRule ^ /(。*)
  
的http:// MYDOMAIN:8080 / filedownload /文件名= $ {逃生:$ 1} [QSA ,L,p]


  
  

看看你重写日志,看看这是否正常工作。


真的很难找到。

I just moved one of our core apps from Windows+IIS+Coldfusion to Ubuntu+Apache+Lucee. The first big problem is the URI encoding for exotic alphabets.

For example, trying to reach this url http://www.example.com/ru/Солнцезащитные-очки/saint-laurent/ results in this record in the Apache access.log:

http://www.example.com/ru/%D0%A1%D0%BE%D0%BB%D0%BD%D1%86%D0%B5%D0%B7%D0%B0%D1%89%D0%B8%D1%82%D0%BD%D1%8B%D0%B5-%D0%BE%D1%87%D0%BA%D0%B8/saint-laurent/

Well, I think that's correctly url-encoded. Then I use a rewrite rule in .htaccess file to get that portion of the url (the cyrillic one) in a url query string parameter (let's say "foo").

Using cflog to dump it, I see in the application log:

/index.cfm?foo=оÑки-длÑ-зÑениÑ&

...which is obviously wrong, because what I need is the original string, in utf-8 cyrillic.

I tried to put URIEncoding parameter in my server.xml tomcat http connector, with no results:

<Connector port="8888" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" 
                URIEncoding="UTF-8" />

How can I get my url parameter in UTF-8?

解决方案

I found the solution by myself.

Source: http://blogs.warwick.ac.uk/kieranshaw/entry/utf-8_internationalisation_with

Apache

Generally you don't need to worry about Apache as it shouldn't be messing with your HMTL or URLs. However, if you are doing some proxying with mod_proxy then you might need to have a think about this. We use mod_proxy to do proxying from Apache through to Tomcat. If you've got encoded characters in URL that you need to convert into some query string for your underlying app then you're going to have a strange little problem.

If you have a URL coming into Apache that looks like this:

http://mydomain/%E4%B8%AD.doc and you have a mod_rewrite/proxy rule like this:

RewriteRule ^/(.*) http://mydomain:8080/filedownload/?filename=$1 [QSA,L,P]

Unfortunately the $1 is going to get mangled during the rewrite. QSA (QueryStringAppend) actually deals with these characters just fine and will send this through untouched, but when you grab a bit of the URL such as my $1 here then the characters get mangled as Apache tries to do some unescaping of its own into ISO-8859-1, but it's UTF-8 not ISO-8859-1 so it doesn't work properly. So, to keep our special characters in UTF-8, we'll escape it back again.

RewriteMap escape int:escape RewriteRule ^/(.*) http://mydomain:8080/filedownload/?filename=${escape:$1} [QSA,L,P]

Take a look at your rewrite logs to see if this is working.

Really hard to find.

这篇关于Lucee URI编码的问题(西里尔文)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆