I have a search form on my site
<form class="clearfix" action="search.php" method="get">
<h1>Search the Site</h1>
<input class="field" type="text" name="q" id="query" value="" size="23" />
<input type="submit" value="Search" class="bt_login" />
</form>
right now it posts to search.php, but I want it to post to /search/query-here. My .htaccess file looks like this right now
ErrorDocument 404 /index.php?p=404
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(products|blog|feed|search|checkout|checkout)$ $1.php [nc]
RewriteRule products/cat/(.*)$ products.php?type=cat&cat=$1 [nc]
RewriteRule products/(.*)$ products.php?type=single&product=$1 [nc]
RewriteRule blog/(.*) blog.php&post=$1 [nc]
RewriteRule feed/(.*) feed.phptype=$1 [nc]
RewriteRule search\.php?q=(.*)$ /search/$1 [R=301,L]
RewriteRule search/(.*)$ search.php?q=$1 [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?wghandcrafted.com/.*$ [NC]
RewriteRule \.(gif|jpg|jpeg|psd|js|swf|flv|png)$ /feed/ [R=302]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^images/.*\.jpg$ /images/default.jpg [L]
How can I accomplish this?
I think that the way to do this, could be to
This would likely be seamless and the user wouldn’t know it had happened.
So…
Revised form with method=”POST” and name=”search_form”
.htaccess
Get URL in the form of http://website.com/search/search+term and rewrite to http://website.com/search.php?q=search+term in the background
PHP