很简单:Mod_rewrite

时间:2012-09-14 20:02:23

标签: mod-rewrite

我有以下重写规则:

RewriteRule ^register/?$ /fitch/index.php?cmd=register [NC,L,QSA]

mysite.com/register的请求被重写为

mysite.com/fitch/index.php?cmd=register

我想允许传递一个可选参数,以便请求 mysite.com/register/sender=models指示我

mysite.com/fitch/index.php?cmd=register&sender=models

2 个答案:

答案 0 :(得分:0)

也许:

RewriteRule ^register/(.*) /fitch/index.php?cmd=register&$1

答案 1 :(得分:0)

对于任意数量的路径 - >查询字符串参数:

RewriteCond %{REQUEST_URI} ^/register/
RewriteRule ^(.*)/(.*)$ /$1&$2 [L]

RewriteCond %{REQUEST_URI} ^/register&
RewriteRule ^(.*)$ /fitch/index.php?cmd=$1 [L,QSA]

这将重写URL,如:

http://mysite.com/register/a=b/1=2/c=d

到:

http://mysite.com/fitch/index.php?cmd=register&a=b&1=2&c=d