fizzy drink
fizzy drink

Reputation: 682

Mod-Rewrite REGEX not working Apache

I am trying to get the following working:

When a user uses a search box, the get sends the user to www.example.com/search/?s=Query+String

Sending the GET request is not a problem, however, grabbing it via a RewriteRule is. I'm not sure my REGEX is proper in this case.

RewriteRule ^search/\?s=(.*[^/])$ search.php?s=$1 [NC,L]

What needs to happen is that the /search/?s=Query+String Query string part has to be taken from that url and sent over to search.php?s=Query+String via the Rewrite Rule

Upvotes: 1

Views: 123

Answers (1)

vmeln
vmeln

Reputation: 1309

Query string from request is stored in variable %{QUERY_STRING}. Rules use %{REQUEST_URI}. Just use QSA flag:

RewriteRule ^search/?$ search.php [NC,L,QSA]

Tested here.

Upvotes: 1

Related Questions