3

I am having an issue with rewriting an url via .htaccess, I have the following url

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

via htaccess I turn it into .../people/search

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

in the url the user can also add a location which should be

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

How can I use rewrite rule to add the two search parameters to the new rewrite url?

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
lagro23
  • 123
  • 1
  • 6

1 Answers1

2

This should be your 2nd rule

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

It rewrites "/people/foo/bar" to "/people.php?search=foo&location=bar"

Try :

RewriteRule ^people/([^/]+)/([^/]+)/?$ people.php?search=$1&location=$2 [NC,QSA,L]
 RewriteRule ^people/([a-zA-Z0-9]+)$ people.php?search=$1 [NC,QSA,L]
Amit Verma
  • 40,709
  • 21
  • 93
  • 115