URL重写,如文字preSS [英] URL Rewrite like wordpress
问题描述
我有重写URL:
现在的问题是,我怎么可以把该值id 3 是公司简介? (3重presenting关于我们中的MySQL数据库)......我们怎么能找回它,使之成为 The question now is how can I turn that id value '3' to be aboutus? (3 is representing 'aboutus' in mysql database)...How can we retrieve it and make it to be 喜欢的东西字preSS URL。 Something like wordpress url. 请指导我..真的AP preciate。 Please guide me.. really appreciate. 您可以添加一个PAGEURL到数据库 You could add a pageUrl into your database 然后通过关于我们在您的网址: Then to pass aboutus in your url: 您会设置这样的: 在page.php你会质疑 On page.php you would query 要你可能使用这样的事情你重定向旧的URL到新的URL在你的.htaccess: To redirect your old url to your new url your probably using something like this in your Htaccess: 要关闭此: To turn this: 您的PHP登陆页面看起来是这样的: You Php landing page would look something like: 这篇关于URL重写,如文字preSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! http://www.abc.com/page.php?id=3
http://www.abc.com/page/3/
http://www.abc.com/page/aboutus/
推荐答案
http://www.abc.com/page/aboutus/
$sql = 'select * from tbl_pages where id= 3';
...other bits....
$pageUrl = stripslashes( $row['pageUrl'] );
$url = 'http://website.com/page/' . $pageUrl . '/';
ID
到 PAGEURL
字段id
to the pageUrl
field$id = $_GET['id'];
$sql = 'select * from tbl_pages where pageUrl = "'.$id."';
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^page.php$ page/%1/? [R=301,L]
page.php ID = 3
到页/公司简介/
虽然你可能有什么打算?创建使用 ID
登陆页面,然后从数据库中,并转发给获取网址。page.php?id=3
into page/aboutus/
though you may have to create a landing page that uses the id
, then gets the url from the database and forwards to that.$sql = 'select * from tbl_pages where id= 3';
...other bits....
$pageUrl = stripslashes( $row['pageUrl'] );
header("HTTP/1.0 301 Moved Permanently");
header("Location: page/" . $pageUrl . "/");
exit;