博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Apache Rewrite.

Posted on 2012-06-07 16:15  钟悍  阅读(209)  评论(0编辑  收藏  举报


1 TraceEnable on
2 RewriteEngine On
3 Rewritecond %{QUERY_STRING} oin=([\S]+)&id=([\S]+)
4 RewriteRule ^/service/([\S]+).xml /service/%2/$1.xml?origin=%1
5 RewriteLog "/var/log/httpd/rewrite.log"

6 RewriteLogLevel 5 

line 3:匹配query_string 中的两个参数

line 4:%1, %2 获取匹配到query_string 中的两个参数

       $1 获取匹配到URL中的第一个参数  

line 5:将Rewrite日志输入到 /var/log/httpd/rewrite.log

line 6:设置RewriteLogLvel

[\S] 表示匹配所有非空字符

example:

http://127.0.0.1:8080/test/service/test.xml?oin=ABC&id=karl

Rewrite to

http://127.0.0.1:8080/test/service/karl/test.xml?oin=ABC