2012-03-01 81 views
0

我试图重写多个页面像这样...阿帕奇重写规则使用正则表达式

http://subdomain.domain.com/index.php?action=printpage;topic=12345.67 

要这个......

http://subdomain.domain.com/index.php/topic,12345.67.html 

我已经失败尝试使用...

RewriteRule ^index\.php\?action=printpage;topic=([0-9]+)\.([0-9]+)$ http://subdomain.domain.com/index.php/topic,$1.$2.html [R=302] 

Apache服务器和我的其他非相关重写工作正常。任何人都可以提供建议吗?谢谢。

回答

1

你不能在一个重写规则对阵查询字符串,你需要使用的RewriteCond和回参考:

RewriteCond %{QUERY_STRING} ^action=printpage;topic=([0-9]+)\.([0-9]+)$ 
RewriteRule ^index\.php$ http://subdomain.domain.com/index.php/topic,%1.%2.html? [R=302]