Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6647665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:33:51+00:00 2026-05-26T00:33:51+00:00

I have a search form on my site <form class=clearfix action=search.php method=get> <h1>Search the

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:33:52+00:00Added an answer on May 26, 2026 at 12:33 am

    I think that the way to do this, could be to

    1. Detect the form has been submitted
    2. Use the header() function to redirect the user to the correct URL.
    3. Let the .htaccess file rewrite the URL in the background
    4. Process the form if the correct variable name is given

    This would likely be seamless and the user wouldn’t know it had happened.

    So…

    Revised form with method=”POST” and name=”search_form”

    <form class="clearfix" action="search.php" method="POST" name="search_form">
                    <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>
    

    .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

    RewriteRule ^search/(.*)$ /search.php?q=$1 [R=301,L]
    

    PHP

    if ($_POST['search_form'])
    {
    
        // Get the search query
        $search_query = $_POST['q'];
    
        header("Location: search/" . urlencode($search_query));
        exit();
    }
    else if ($_GET['q'])
    {
        $query_from_url = $_GET['q'];
    
        echo "The query from the URL is" . $query_from_url;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have form with two buttons submit. The code is: <form action=index.php method=get> <table
I have a search form: <form class=searchForm id=topSearchForm action=/search.ds> that has an onsubmit-event attached
I have this stemmed field: <fieldtype name=textes class=solr.TextField> <analyzer type=index> <tokenizer class=solr.WhitespaceTokenizerFactory/> <filter class=solr.WordDelimiterFilterFactory
I have a simple search form (site/search.php) to send search string to controller and
I have a form that submits a search for blogs on my site via
(Using MySQL and PHP) I have a search form that will allow my users
I have a simple search form with a box and a button. <form action
I have a text input with a search buton absolute positioned over it... to
On this site , I have a search form whose submit button has a
I have a search form i made for a wordpress site.....visually it is good

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.