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"
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