简体   繁体   中英

Rewrite URL from my form using get request in htaccess

I just want to rewite my url example.org/search.php?by_what=date&keywords=sample to example.org/search/date/sample .

Here is my code : in my search.php

<form name="frmSearch" action="search.php" method="GET">

            <div class="row searchbox-container">
                <div class="twelve columns">
                    <div class="row collapse">
                        <div class="nine columns">
                            <input type="hidden" name="by_what" value="manning_agency">
                            <center>
                                <input type="text" placeholder="Type agency name here" name="keywords" id="keywords" size="40" class="small-txtbox-search-inner" value="<? echo $keywords; ?>" />
                            </center>
                        </div>

                        <div class="three columns">  
                            <input type="submit"  class="button expand postfix"  name="" id="cmdSubmit" value="Search" style="font-weight:normal !important; padding:7px !important; width:120px" />
                        </div>
                    </div>
                </div>
            </div>

        </form>

and here is my .htaccess :

Options +FollowSymLinks 

RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^search/(.*)$ search.php?$1 [QSA,L]

RewriteCond %{THE_REQUEST} ^[a-zA-Z0-9]{3,9}\ /search\.php\?by_what=([^&]+)&keywords=([^&]+)(.*)\ HTTP/

RewriteRule ^search\.php$ example.org/search/%2/q/%1? [R=301]

You can use these rules:

Options +FollowSymLinks -MultiViews    
RewriteEngine on

RewriteCond %{THE_REQUEST} /search\.php\?by_what=([^&\s]+)&keywords=([^&\s]+)\s [NC]
RewriteRule ^ /search/%1/%2? [R=301,L,NE]

RewriteRule ^search/([^/]+)/([^/]+)/?$ search.php?by_what=$1&keywords=$2 [QSA,L,NC]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM