不错的搜索网址

编程入门 行业动态 更新时间:2024-10-25 16:20:58
本文介绍了不错的搜索网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个提交到搜索页面的表单。我可以在后端处理MOD_REWRITE的东西,但想知道以最好的格式获得搜索结果页面的最佳方法。

I have a form which submits to a search page. I can handle the MOD_REWRITE stuff at the back end but want to know the best way to get the search result page in a nice format in the first place.

最好吗?接收表单提交,然后重定向到更好的URL结构。在以下示例中,用户搜索 blah 。

Is it best to receive the form submission, then redirect to a nicer url structure. In the following example the user searches for blah.

/search.html?searchterm=blah

哪个重定向到

/search/blah/

或者我可以(我的首选项)在用户点击提交按钮后以某种方式使用javascript(或jQuery)执行此操作?

Or can I (my preferred option) do this using javascript (or jQuery) somehow after the user clicks the submit button?

推荐答案

绝对应该阅读此内容教程:

definitely you should read this tutorial:

  • matthewjamestaylor/blog/how-to-post-forms-to-clean-rewritten-urls
    • matthewjamestaylor/blog/how-to-post-forms-to-clean-rewritten-urls
    • 基础:

    • mysql_real_escape_string()搜索字词
    • 删除所有非Alpha / Num字符
    • 在每个匹配的单词之间放置 +
    • SELECT MATCH AGA INST || 在BOLEAN模式 || LIKE
    • mysql_real_escape_string() searched term
    • remove all non Alpha/Num chars
    • place the + between each matched word
    • SELECT MATCH AGAINST || IN BOLEAN MODE || LIKE
    • mod_rewrite

      RewriteRule ^search/([^/\.]+)$ search.php?q=$1

      PS:链接中的 PHP 部分是有点outofdate,所以,例如你应该使用 preg_replace 而不是 ereg_replace ,你也可以避免额外的步骤通过在第一次尝试中完成所有操作来剥离空间;你也可以检查停用词并按照建议的:foo-bar来优化你的正则表达式。还有其他事情要考虑,但新手是一个很好的起点。

      PS: the PHP part in the link is a little bit outofdate, so, for example you should use preg_replace instead of ereg_replace, and you can also avoid the extra step of stripping spaces by doing it all in the first try; you may also check for stopwords and refine your regex as suggested ex.: foo-bar. there are other things to consider but for a novice is a good starting point.

更多推荐

不错的搜索网址

本文发布于:2023-11-28 19:30:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643674.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网址

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!