This is a multi-part message in MIME format.
--------------060001090603040001090701
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

let me explain in Chinese,

in the org.conf
--------------------------------

use lib qw(/var/org);


PerlModule Zorpia::RewriteOrg
PerlTransHandler Zorpia::RewriteOrg
--------------------------------

The PerlTransHandler 能把 url 转变为另一个 url, 比如我们就是将类如
http://org.zorpia.com/0/1584/10141597.0f8688.jpg
这*的 url 转变为
http://org.zorpia.com/org62/0/1584/10141597.0f8688.jpg

这里*为要访问数据库,所以用 mod_rewrite 是不行的。只能依* modperl
而 modperl 只是跟 Apache 打交道,不能将这个地址访问到另外 务器上的文
件。(也就是访问不到 org62 这个服务器)。当然它可以发送一个 header:
Location 转到 org62, 但是这**地址*是会变到 org62 。

怎么*才能在这个 apache 里访问 org62 服务器上的东西。那只能依* mod_proxy
--------------------------------
RewriteEngine On
RewriteLog /var/log/httpd/rewrite_log
RewriteLogLevel 3
RewriteRule ^/org(\d+)/(.*) http://org$1.zorpia.com/$2 [proxy,last]
--------------------------------
这*我们就可以将 http://org.zorpia.com/org62/0/1584/10141597.0f8688.jpg
用 proxy 访问 http://org62.zorpia.com/0/1584/10141597.0f8688.jpg
对于用户来说这是不可见的。

That's ALL.

而 PerlTransHandler Zorpia::RewriteOrg 也很简单。
--------------------------------
if ($r->uri =~ m|/(\d+)/(\d+)/([\w\.]+)\.jpg$|) {
my $org = &get_org_from_photo_id($1, $2);
$r->uri("/org$org/$1/$2/$3\.jpg");
}
--------------------------------
将访问的 url 转一下。老板*看看就明白了。

另外我想说的是,目前我用的是 Apache2 和 modperl2, *为 alpha.zorpia 这台
机*用的是这两个版本的。如果要转 apache 1.3 和 modperl1 也是很容易的。
还有就是 log 问题。如果到最后发布的时候不需要 log(这*能稍微节省一点点
资源),就把 conf 里的 RewriteLog 和 RewriteLogLevel 注释掉。还有
RewriteOrg.pm 与 Apache2::Log 相关的内容。
另外还有个是 RewriteOrg.pm 目前是直接用 DBI 连接的。如果有可能我们可以迁
移到 Apache:BI.

Thanks. 如果有问题就问我。 我拿着工资的。呵呵。

--------------060001090603040001090701
Content-Type: text/plain;
name="org.conf"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="org.conf"

PFZpcnR1YWxIb3N0ICo6ODA+CiMJRG9jdW1lbnRSb290IC92YX Ivd3d3L1pvcnBpYQoKIyAg
ICBTZXRFbnYgUEVSTDVMSUIgIi92YXIvd3d3L2ZheWxhbmQvWm 9ycGlhL2xpYiIKIyAgICBQ
ZXJsU3dpdGNoZXMgLUkvdmFyL3d3dy9ab3JwaWEvbGliCgk8UG VybD4KCXVzZSBsaWIgcXco
L3Zhci9vcmcpOwoJPC9QZXJsPgoKICAgIFBlcmxNb2R1bGUgWm 9ycGlhOjpSZXdyaXRlT3Jn
CiAgICBQZXJsVHJhbnNIYW5kbGVyIFpvcnBpYTo6UmV3cml0ZU 9yZwoKICAgIFJld3JpdGVF
bmdpbmUgT24KICAgIFJld3JpdGVMb2cgL3Zhci9sb2cvaHR0cG QvcmV3cml0ZV9sb2cKICAg
IFJld3JpdGVMb2dMZXZlbCAzCiAgICBSZXdyaXRlUnVsZSBeL2 9yZyhcZCspLyguKikgaHR0
cDovL29yZyQxLnpvcnBpYS5jb20vJDIgW3Byb3h5LGxhc3RdCg ogICAgRXJyb3JMb2cgL3Zh
ci9sb2cvaHR0cGQvb3JnLmxvZwogICAgU2VydmVyTmFtZSBvcm cuem9ycGlhLmNvbQo8L1Zp
cnR1YWxIb3N0Pgo=
--------------060001090603040001090701
Content-Type: text/plain;
name="RewriteOrg.pm"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="RewriteOrg.pm"

cGFja2FnZSBab3JwaWE6OlJld3JpdGVPcmc7CiAgCiN1c2UgQX BhY2hlOjpDb25zdGFudHMg
cXcoREVDTElORUQpOwp1c2UgQXBhY2hlMjo6UmVxdWVzdFJlYy AoKTsKdXNlIEFwYWNoZTI6
OkNvbnN0IC1jb21waWxlID0+IHF3KERFQ0xJT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ICAgICAgeyBQcmludE Vycm9yID0+IDEsCiAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgUmFpc2VFcnJvciA9Pi AxLAogICAgICAgICAgICAg
ICAgICAgICAgICAgICAgIEF1dG9Db21taXQgPT4gMSwgfSkgb3 IgZGllICREQkk6OmVycnN0
cjsKICAgIAogICAgbXkgJHNxbF9zdGF0ZW1lbnQgPSA8PFNRTF 9TVEFURU1FTlQ7ClNFTEVD
VCBzZXJ2ZXIsIGJhc2VfZGlyZWN0b3J5IEZST00gZGlyZWN0b3 J5X2xvY2F0aW9uIApXSEVS
RSBkaXJlY3RvcnlfMSA9ID8gQU5EIGRpcmVjdG9yeV8yID0gPy BBTkQgdHlwZT0nb3JnJwpT
UUxfU1RBVEVNRU5UCiAgICBteSAkc3RoID0gJGRiaC0+cHJlcG FyZSgkc3FsX3N0YXRlbWVu
dCk7CiAgICAkc3RoLT5leGVjdXRlKCRkaXJlY3RvcnlfMSwgJG RpcmVjdG9yeV8yKTsKICAg
IG15ICgkc2VydmVyLCAkYmFzZV9kaXJlY3RvcnkpID0gJHN0aC 0+ZmV0Y2hyb3dfYXJyYXk7
CiAgICAkc3RoLT5maW5pc2g7CgogICAgbXkgJGluZGV4XzEgPS AkMSBpZiAoJHNlcnZlciA9
fiBtLyhcZCspJC8pOwoJbXkgJGluZGV4XzIgPSAkMSBpZiAoJG Jhc2VfZGlyZWN0b3J5ID1+
IG0vKFxkKykkLyk7CgogICAgcmV0dXJuICIkaW5kZXhfMSRpbm RleF8yIjsKfQoKMTs=
--------------060001090603040001090701--