加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

从php和sql创建动态自动递增seo友好url

发布时间:2020-12-13 22:47:51 所属栏目:PHP教程 来源:网络整理
导读:点击用户John Smith的位置user_id 1它应该转到网址www.example.com/John-Smith而不是profile.php?uid = 1 当你在user_id 2中点击用户John Smith时,它应该转到网址www.example.com/John-Smith-2 profile.php?UID = 2 当你在user_id 3中点击用户Kia Dull时,
点击用户John Smith的位置user_id 1它应该转到网址www.example.com/John-Smith而不是profile.php?uid = 1

当你在user_id 2中点击用户John Smith时,它应该转到网址www.example.com/John-Smith-2
profile.php?UID = 2

当你在user_id 3中点击用户Kia Dull时,它应该转到网址www.example.com/Kia-Dull
profile.php?UID = 3

Table Users

User_id    First_name    last_name
   1          John         Smith
   2          John         Smith
   3          Kia          Dull

我如何格式化.Htaccess文件和php / sql.

单击用户配置文件时,我只需将其引导至此处即可.

<a href="<?php echo $row[first_name] ?>-<?php echo $row[last_name] ?>"

什么也没做.

这是我的.htaccess

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)$profile.php?uid=$1 [L]

解决方法

看看下面的文章.希望它描述清晰/简单,并举例说明您的需求.

SEO Friendly URLs with PHP

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读