有个搜索框,搜索后实现地址是show.php?q=xxx,想让其显示为show.html?q=xxx,通过Rewrite实现。
直接想当然的写出:
RewriteRule ^show.html?q=(\w+)$ show.php?q=$1
失败,根本不认这条。
查了下文档,似乎应该用RewriteCond来实现,测试了N回,终于成功。
RewriteCond %{QUERY_STRING} ^(q=.*)$
RewriteRule ^show.html(.*) show.php?%1 [L]
%1就是获取到的q=xxx啦:)