嗨,我的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
谢谢。
发布于 2013-04-28 20:35:17
此重写规则将接受/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]发布于 2013-04-28 20:35:27
首先,必须更改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]https://stackoverflow.com/questions/16262809
复制相似问题