- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚将我们的一个核心应用程序从 Windows+IIS+Coldfusion 迁移到 Ubuntu+Apache+Lucee。第一个大问题是外来字母表的 URI 编码。
例如,尝试访问此 URL http://www.example.com/ru/Солнцезащитные-очки/saint-laurent/
会在 Apache 访问日志中产生以下记录:
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 编码。然后我在 .htaccess 文件中使用重写规则来获取 url 查询字符串参数(假设为“foo”)中的那部分 url(西里尔字母)。
使用cflog转储它,我在应用程序日志中看到:
/index.cfm?foo=оÑки-длÑ-зÑениÑ&
...这显然是错误的,因为我需要的是 utf-8 西里尔字母的原始字符串。
我试图将 URIEncoding 参数放入我的 server.xml tomcat http 连接器中,但没有结果:
<Connector port="8888" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
如何获取 UTF-8 格式的 url 参数?
最佳答案
我自己找到了解决方案。
来源: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.
真的很难找。
关于apache - Lucee URI 编码问题(西里尔文),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30273939/
我想开发一个 Skype 机器人,它将用户名作为输入,并根据用户输入以相反的字符大小写表示hello username。简而言之,如果用户输入他的名字 james,我的机器人会回复他为 Hello J
我是一名优秀的程序员,十分优秀!