php和htaccess,通过mysql表id和其他列重写url

php和htaccess,通过mysql表id和其他列重写url,php,mysql,.htaccess,Php,Mysql,.htaccess,嗨,我的mysql表是这样的 [ID] [TITLE] [SEOLINK] [1] [Test] [test] [2] [Test 2] [test-2] 我的php url是这样的 example.com/index.php?id=2 如何进行htaccess重写,以便链接可以 example.com/page/test-2 谢谢。此重写规则将接受/page/This-is-my-page-title-123格式的URL,其中123是页面id 它还将具有QueryString感知功能,这意味

嗨,我的mysql表是这样的

[ID] [TITLE] [SEOLINK]
[1] [Test] [test]
[2] [Test 2] [test-2]
我的php url是这样的 example.com/index.php?id=2

如何进行htaccess重写,以便链接可以 example.com/page/test-2


谢谢。

此重写规则将接受/page/This-is-my-page-title-123格式的URL,其中123是页面id

它还将具有QueryString感知功能,这意味着您可以在末尾添加?param=value,这将被处理

RewriteEngine On
RewriteRule ^page/[\w\-]+(\d)+ /index.php?id=$1 [L,QSA,NC]

首先,必须改变mysql的条件

$query = "select * from TABLE where ID = '".$_GET['id']."'";
mysql_query($query);

to 

$query = "select * from TABLE where SEOLINK = '".$_GET['param']."'";
mysql_query($query);
现在,您可以在.htaccess中使用重定向规则。比如:

RewriteRule ^page/(.*)$ http://example.com/index.php?param=$1 [NC]