Use form variables in url

wal_toor
wal_toor used Ask the Experts™
on
Hello all,

I have this little searchbox that does the trick:

<form action="http://www.mywebsite.com/projects/search" method="post" accept-charset="utf-8" name="searchform" id="searchform">
<input type="text" name="search_input" value="" id="search_input">
<input type="submit" name="search_button" value="Go" id="search_button" class="button button_blue">
</form>

Open in new window


I really would like to share the search url with other people (nice clean url without the get variables), so if a user searches for the word 'books' the url that should be loaded/displayd should become:

http://www.mywebsite.com/projects/search/books

Open in new window


Can this be done? And how?

Greetz,
walter
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
http://www.mywebsite.com/projects/search?search_input=books

Changed to
http://www.mywebsite.com/search/books

Create a TXT file names ".htaccess"  Upload it to the root of your server.

This should be included in the file

RewriteEngine On
RewriteEngine On
RewriteRule ^search_input/([^/]*)$ /projects/search?search_input=$1 [L]

Open in new window


Your form Need to be "GET" Not post
aND cHANGE name="search"  like below.
<form action="http://www.mywebsite.com/projects/search" method="GET" accept-charset="utf-8" name="[b]searchform[/b]" id="searchform">
<input type="text" name="search" value="" id="search_input">
<input type="submit" name="search_button" value="Go" id="search_button" class="button button_blue">
</form>

Open in new window


Anly change the "www.mywebsite.com"  for this to wotk.



See here for more help
http://www.generateit.net/mod-rewrite/

Author

Commented:
Ah mod_rewrite.. had'nt thought of that yet. Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial