问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/15411898/mod-rewrite-regex-not-working-apache