URL重写,如文字preSS重写、文字、URL、preSS

2023-09-02 20:34:41 作者:迩若敢嫁、俄⑨敢娶

我有重写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;