搜索伪静态设置很久都无法实现。

Mada 2023-2-11 985

form id="search_form" name="formsearch" action="/index.php" onsubmit="return  checkIndexpost();">
                <input type="hidden" name="u" value="search-index" />
                <input type="text" name="keyword"  placeholder="快速搜索百科知识!" />
                <button type="submit">快速搜索</button>
              </form>

我看了群里某人网站都设置了搜索的时候是:search/xxx   这样得搜索链接。我要怎么设置呢?是在上面代码操作还是?

最新回复 (1)
  • im3e 2023-3-1
    2
    =搜索伪静态,只适用于 3.0 版本=

    1、<form>标签里,要添加 id 值 search_form,形如:

         <form action="/index.php" method="get" id="search_form">

    2、请在页面最底部,添加如下JS代码。

    <script>
    (function() {
                $("#search_form,#search_form2").submit(function() {
                var mid = $(this).find("[name='mid']").val();
                var keyword = $(this).find("[name='keyword']").val();
                window.location.href = "/search/" + encodeURIComponent(keyword) + "/";
                return false;
                });
                })();
    </script>
返回
发新帖