How to add an htaccess rule for a search page so that it will work with and without query parameter

Is it possible for me to add an htaccess rule for a search page so that it will work with and without query parameter. I ll add the example below

Actual file is www.mysite.com/search.php

Below 2 links should work for me

  1. www.mysite.com/search/loremipsum

  2. www.mysite.com/search/?query=loremipsum

The rule I have added on htacess is given below

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^search/?$ search.php? [L]
RewriteRule ^search/([^/]+)$ search.php?query=$1 [L]

Any help will be much apprecited