Php html中的服务器页面动态获取数据

Php html中的服务器页面动态获取数据,php,apache,Php,Apache,实际上我有一个搜索引擎,我想在html页面中显示我的搜索结果 比如说 用户可以在我的网站上搜索的一种方法是访问url,如 http://mysite.com/search.php?q=“关键字” 但是我想以这种方式在我的网站上进行搜索查询 http://mysite.com/search/keywords.html 而keyword.html不是我网站上的静态页面,而是在搜索查询时动态创建的 那么,如何使用php或apache.htaccess文件实现这一点呢。我用谷歌搜索了一下,但找不到答案

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

比如说

用户可以在我的网站上搜索的一种方法是访问url,如

http://mysite.com/search.php?q=“关键字”

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

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

而keyword.html不是我网站上的静态页面,而是在搜索查询时动态创建的 那么,如何使用php或apache.htaccess文件实现这一点呢。我用谷歌搜索了一下,但找不到答案


因此,plz帮助

您可以尝试以下内容:

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

RewriteRule ^(.+) /index.php?query=$1.html
RewriteEngine on
RewriteRule ^/?([0-9a-z]+)\.html$ search.php?q=$1 [L]
请注意,此规则可能会影响文件夹中的其他媒体文件。因此,最好将它们移到别处(子域中)

您可能希望使用类似的方法:

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

RewriteRule ^(.+) /index.php?query=$1.html
RewriteEngine on
RewriteRule ^/?([0-9a-z]+)\.html$ search.php?q=$1 [L]

您可以先做一个表单

使用php

search_result.php应该是这样的,看看吧