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?

1 Answer 1

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]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.