你好我的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
谢谢。
最佳答案
首先,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
中使用 RedirectRule
。喜欢:
RewriteRule ^page/(.*)$ http://example.com/index.php?param=$1 [NC]
关于php 和 htaccess,通过 mysql 表 id 和其他列重写 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16262809/