0

I'm building a single page app by loading view files into the template (index.php) - which is working well - except for searching.

My URL

http://testdomain.loc/members/search/?s=foo+bar

My Rule

RewriteRule ^members/search/(.*)$ index.php?view=members-search&keywords=$1 [L]

This is loading the correct view, but it's not passing the keyword parameters, so when I print_r($_GET), this is what I see...

(
    [view] => members-search
    [keywords] => 
)

What's the correct way to do this?

timgavin
  • 4,972
  • 4
  • 36
  • 48

1 Answers1

0

The RewriteRule is only matching the path, not the query parameters. You'll want to append the original query parameters to the rewritten URL using QSA:

RewriteRule ^members/search/ index.php?view=members-search [L,QSA]

If you actually wanted to match on the query parameters, you'd have to do so in a RewriteCond:

RewriteCond %{QUERY_STRING} s=(.*)
RewriteRule ^members/search/ index.php?keywords=%1 [L]

(Not quite sure if this will work exactly as is, but something along those lines. QSA will be a lot simpler either way.)

deceze
  • 510,633
  • 85
  • 743
  • 889