开发者

How to create a search , search engine friendly ( mod_rewrite htaccess )

开发者 https://www.devze.com 2023-01-06 17:46 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消