2

实际上我有一个搜索引擎,我想在 html 页面中显示我的搜索结果

例如

用户可以在我的网站上搜索的一种方法是访问类似的网址

http://mysite.com/search.php?q='KEYWORDS'

但我想以这种方式在我的网站上进行搜索查询

http://mysite.com/search/keywords.html

虽然 keyword.html 不是我网站上的静态页面,而是在搜索查询时动态创建的,所以我如何使用 php 或 apache .htaccess 文件来完成这项工作。我用谷歌搜索但找不到答案

所以请帮忙

4

3 回答 3

1

您可能想使用类似这样的mod_rewrite :

RewriteEngine on
RewriteRule ^/?([0-9a-z]+)\.html$ search.php?q=$1 [L]
于 2012-11-22T13:08:50.547 回答
0

你可以尝试这样的事情:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !index.php
RewriteBase /

RewriteRule ^(.+) /index.php?query=$1.html

请注意,此规则可能会影响您文件夹中的其他媒体文件。所以最好将它们移到别处(在子域中)。

于 2012-11-22T13:07:28.837 回答
-1

你可以做的是先做一个表格

use php

search_result.php 应该是这样的看看

结果文件点击这里

于 2012-11-22T13:28:24.557 回答