如何重写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
。
答案 0 :(得分:0)
要获取查询字符串值,您需要使用RewriteCond
之类的:
RewriteCond %{QUERY_STRING} ^var1=([^&]*)&var2=([^&]*)
RewriteRule ^index.php/dir/controller$ /rewrite-string/%1/%2 [R=301,NC,L]
并按%
而非$