Thursday, April 1, 2010

apache mod_rewrite with percent signs

This article shows a little bit how to use mod_rewrite.

The scenario is
1. A client connects to the web server with a '%'-signed URL.
For example, when you use MBSC(e.g. Korean), the URL turns into other form.
http://test.com/테스트 => http://test.com/%C5%D7%BD%BA%C6%AE

The Solution is the followings. But I don't know the internals.

httpd.conf
RewriteEngine on
RewriteRule /테스트 http://test.com [R]
RewriteLog "rewrite.log"
RewriteLogLevel 10

rewrite.log
localhost - - [01/Apr/2010:14:38:07 +0900] [test.com/sid#94f2490][rid#95481a0/initial] (2) init rewrite engine with requested uri /테스트
localhost - - [01/Apr/2010:14:38:07 +0900] [test.com/sid#94f2490][rid#95481a0/initial] (3) applying pattern '/%C5%D7%BD%BA%C6%AE' to uri '/테스트'
localhost - - [01/Apr/2010:14:38:07 +0900] [test.com/sid#94f2490][rid#95481a0/initial] (1) pass through /테스트
localhost - - [01/Apr/2010:14:39:46 +0900] [test.com/sid#8785490][rid#87db118/initial] (2) init rewrite engine with requested uri /테스트
localhost - - [01/Apr/2010:14:39:46 +0900] [test.com/sid#8785490][rid#87db118/initial] (3) applying pattern '/테스트' to uri '/테스트'

0 comments:

Post a Comment