How do I redirect /search/ to ?s=

I have a Search page set up which uses the typical GET format

    <form id="searchform" action="http://example.com" method="get">
        <input id="s" type="text" name="s" placeholder="Search Again">
    </form>

For users’ convenience, I’d like to have the following url redirect to the search page:

http://example.com/search?search-term

Redirect to:

http://example.com/?s=search-term

I also want the rewrite or redirect to handle the case of NO search parameters. That is, when the URL is simply /search or /search/ I’d still like the page to redirect to the Search template.

How do I do this?

Solutions Collecting From Web of "How do I redirect /search/ to ?s="

In your .htaccess add the following rule in between the <IfModule mod_rewrite.c> tag:

RewriteCond %{QUERY_STRING} (^|&)(.*)
RewriteRule ^(.*)$ /?s=%2 [R=301,L]

Based off of the default .htaccess generated by WordPress, it should now look like the following with your custom RewriteRule:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# Custom Rules
RewriteCond %{QUERY_STRING} (^|&)(.*)
RewriteRule ^(.*)$ /?s=%2 [R=301,L]
</IfModule>