Forum Moderators: phranque
I am creating a small search form where a user can search a mysql database of widgets. I am using method="get" in my <form> which when submitted takes you to the following URI:
http://www.example.com/search.php?keyword=widget.
What I want is the form to direct the browser to the this URI instead.
http://www.example.com/search/widget/
Is this possible to achieve as the form is handling a variable to perform the mysql query later on.
i.e
SELECT * FROM table where widget='$keyword'
Regards,
Change the links on the page to the 'friendly' URL-format. Users will click those new links, sending a request to your server. In order to serve content for those URLs (which don't resolve to 'real' files), you must then internally rewrite those requests to the proper script, with the keyword copied to the query string appended to the local URL-path of the script.
Further, you may wish to redirect direct client requests for the 'unfriendly' URLs back to the 'friendly' URLs, so that the 'unfriendly' ones will be removed from search engine listings. So, this can be up to a three-part process.
More info here [webmasterworld.com].
Jim
I understand briefly how mod_rewrite works but as I understand mod_rewrite cannot change URI's therefore my main priorty is getting the submit button to direct the user to http://www.example.com/search/widget/.
Thank you for your time
Since the question isn't very focused, I'll just suggest that you'd do this by modifying the URL used by the POST action in the HTML form ("Submit" activates the "POST" action).
The URLs on/in your pages define the URLs seen by the client, and mod_rewrite can't change them. All it can do is to internally rewrite a URL, when received in an HTTP request from the client, to a non-default filepath within the server, or to externally redirect it to another URL -- an action which is visible to the client (and user), and in which the client must take action to complete.
Jim