I have this search form in my drupal site.

<form id="mysearch" method="get" action="<?php echo $base_url.'/search/node/'; ?>">
   <input type="text" maxlength="150" id="search" name="s" class="input">
   <input type="submit" value="Search" class="button">

I have problem is that when I am submit the form it will pass the query like that


Here I would like to change the URL something like this to search in my site.


Can anyone help me how can i achieve this thing.

I have put this code for URL Change:

$("#adminbarsearch").submit(function(e) {
    $url = $("#adminbarsearch").attr("action") + $( "input:first" ).val();
    window.location.href = $url;

Instead of this Can we change the URL by using the .htaccess

  • jQuery code is working fine. – AshwinP Sep 18 '13 at 5:39

If you use the default search block for Drupal, it will give you the functionality you need.

EDIT: Go to Structure > Blocks and enable your Search Form Block by adding it to a region.

If you perform a search using your default search block, it will redirect to a path in the format /search/node/QUERY where QUERY is what you are searching for.

By default the search form outputs (for example):

<div class="block-wrapper">
    <div class="block-container">
        <div class="block">
            <div class="content">
                <form action="/" method="post" id="search-block-form" accept-charset="UTF-8">
                    <div class="container-inline">
                        <h2 class="element-invisible">Search form</h2>
                            <div class="form-item form-type-textfield form-item-search-block-form">
                                <label class="element-invisible" for="edit-search-block-form--2">Search</label>
                                <input title="Enter the terms you wish to search for." type="text" id="edit-search-block-form--2" name="search_block_form" value="" size="15" maxlength="128" class="form-text">
                            <div class="form-actions form-wrapper" id="edit-actions">
                                <input type="submit" id="edit-submit" name="op" value="Search" class="form-submit">
                            <input type="hidden" name="form_build_id" value="form-4gEUIDHcVH7lHHH3JpkfkVs9xBmPhHXdDQAMFMF9dHA">
                            <input type="hidden" name="form_token" value="afNo5gRQlaauXmqeZYDf80o5dEwKlg0VP6U-Ir8-p6k">
                            <input type="hidden" name="form_id" value="search_block_form">

Now if I search for "test", it redirects to /search/node/test

|improve this answer|||||
  • Can you explain more How I can pass param in querystring without "?" – AshwinP Sep 19 '13 at 4:42
  • I've added more info to my answer – Scott Joudry Sep 19 '13 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.