Welcome! Log In Create A New Profile

Advanced

Re: Is there some way to implement the function of mod_encoding in Apache httpd?

agentzh
June 15, 2011 08:14AM
On Tue, Jun 14, 2011 at 4:01 PM, sunjipeng_neu <nginx-forum@nginx.us> wrote:
> How can I map the uri to local file path between different charset?
>
> Such as, the uri is encode with UTF-8 but my local file system charset
> is GBK or EUCKR or EUCJP.
>

Here's an example for utf-8 -> euc-kr:

location / {
set_iconv $new_uri $uri from=utf8 to=euc-kr;
if ($uri = $new_uri) {
break;
}
rewrite ^ $new_uri;
}

This *should* work out of the box if you have compiled the ngx_iconv
module into your nginx server:

https://github.com/calio/iconv-nginx-module

It's not the most efficient though because set_iconv will always be
called twice. Here's a modified but slightly complicated way:

location / {
}

location ~ '^/euc-kr(/.+)' {
set $path $1;
set_iconv $new_path $path from=utf8 to=euc-kr;
rewrite ^ $path;
}

But now it requires you to invoke /enc-kr/foo/bar.html instead of the
original /foo/bar.html.

If you want the file content sent to the content to be converted to
UTF-8, you can use the iconv_filter directive provided by the
ngx_iconv module.

Hope this helps,
-agentzh

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Is there some way to implement the function of mod_encoding in Apache httpd?

sunjipeng_neu June 14, 2011 04:01AM

Re: Is there some way to implement the function of mod_encoding in Apache httpd?

姚伟斌 June 15, 2011 06:52AM

Re: Is there some way to implement the function of mod_encoding in Apache httpd?

agentzh June 15, 2011 08:14AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 173
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready