URL重写,如文字preSS [英] URL Rewrite like wordpress

查看:139
本文介绍了URL重写,如文字preSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有重写URL:

http://www.abc.com/page.php?id=3

http://www.abc.com/page/3/

现在的问题是,我怎么可以把该值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

http://www.abc.com/page/aboutus/

喜欢的东西字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:

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 . '/';

在page.php你会质疑 ID PAGEURL 字段

On page.php you would query id to the pageUrl field

$id = $_GET['id'];
$sql = 'select * from tbl_pages where pageUrl = "'.$id."';

要你可能使用这样的事情你重定向旧的URL到新的URL在你的.htaccess:

To redirect your old url to your new url your probably using something like this in your Htaccess:

RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^page.php$ page/%1/? [R=301,L]

要关闭此: page.php ID = 3 页/公司简介/ 虽然你可能有什么打算?创建使用 ID 登陆页面,然后从数据库中,并转发给获取网址。

To turn this: 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.

您的PHP登陆页面看起来是这样的:

You Php landing page would look something like:

$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;

这篇关于URL重写,如文字preSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆