htaccess rewriterule在url中的2个参数

时间:2015-09-09 02:16:21

标签: php apache .htaccess mod-rewrite url-rewriting

我遇到通过.htaccess重写网址的问题, 我有以下网址

 www.website.com/people.php?search=search

通过htaccess我将其转为.../people/search

 RewriteRule ^people/([a-zA-Z0-9]+)$ people.php?search=$1
 RewriteRule ^people/([a-zA-Z0-9]+)/$ people.php?search=$1search=$1

在网址中,用户还可以添加一个应该

的位置
 www.website.com/people.php?search=something&&location=something

如何使用重写规则将两个搜索参数添加到新的重写网址?

1 个答案:

答案 0 :(得分:2)

这应该是你的第二条规则

    <dependency>
        <groupId>io.dropwizard</groupId>
        <artifactId>dropwizard-client</artifactId>
        <version>0.8.4</version>
        <scope>compile</scope>
    </dependency>

它将“/ people / foo / bar”重写为“/people.php?search=foo&location=bar”

尝试:

RewriteRule ^people/([^/]+)/([^/]+)/?$ people.php?search=$1&location=$2 [NC,QSA,L]