开发者

mod_rewrite Problem with rewriting optional query from FORM

开发者 https://www.devze.com 2023-03-26 18:27 出处:网络
RewriteRule ^([^/.]+)?orderby=([^/.]+)&sort=([^/.]+)$ index.php?category=$1&orderby=$2&sort=$3 [L,NC]
    RewriteRule ^([^/.]+)?orderby=([^/.]+)&sort=([^/.]+)$ index.php?category=$1&orderby=$2&sort=$3 [L,NC]
    RewriteRule ^([^/.]+)$ index.php?category=$1 [L,NC]

my html code is like this

    <form method="get" action="">....

If I submit the form the URL is like this: http://site.com/category?orderby=hits&sort=desc (The variables orderby and sort don开发者_JAVA技巧t work) It looks like my first rule is ignored.


use [QSA] flag (means query string append)

RewriteRule ^([^/.]+)$ index.php?category=$1 [L,NC,QSA]

RewriteRule does not use query string to match url

0

精彩评论

暂无评论...
验证码 换一张
取 消