如何重写domainname.com/index.php/dir/controller/?var1=abc&var2=def

时间:2012-11-03 04:09:16

标签: .htaccess url-rewriting

如何重写domainname.com/index.php/dir/controller/?var1=abc&var2=def

domainname.com/rewrite-string/abc/def/

domainname.com/rewrite-string/abc/def/是用户放置到浏览器地址栏的链接

,服务器会将其重定向到domainname.com/index.php/dir/controller/?var1=abc&var2=def

1 个答案:

答案 0 :(得分:0)

要获取查询字符串值,您需要使用RewriteCond之类的:

RewriteCond %{QUERY_STRING} ^var1=([^&]*)&var2=([^&]*)
RewriteRule ^index.php/dir/controller$  /rewrite-string/%1/%2 [R=301,NC,L]

并按%而非$

引用匹配组