How to create a search , search engine friendly ( mod_rewrite htaccess )
I want to know if it's possible to create a GET form that has as action "search.php?wh开发者_如何学运维at=bla bla" and in the url bar it shows "search/bla bla" . Then I can handle the search file and explode the search terms, but what is the rewrite rule?
You can't create the form to generate the URL in the desired format, and it's not of any use search engine wise.
However, when for example listing 'recent searches', you can list the URLs in the format search/bla%20bla
, and use the rewrite rule given by Patrick.
Be very careful with your input validation BTW.
You can put the following code in your .htaccess file:
RewriteEngine on
RewriteRule ^/search/(.*)$ /search.php?what=$1
I discovered a way to do what I wanted to do.
<form action="search.php" method="GET" id="form23" name="form23">
<input type=text id=what name=what />
<input type=button value="go" OnClick="document.location='cauta/'+document.form23.what.value;" />
</form>
But remember this is only for people's browsing experience.
精彩评论