点击位置 user_id 1 的用户 John Smith 它应该转到 url www.example.com/John-Smith 而不是 profile.php?uid=1
当您点击 user_id 2 中的用户 John Smith 时,它应该转到 url www.example.com/John-Smith-2 profile.php?uid=2
当您点击 user_id 3 中的用户 Kia Dull 时,它应该转到 url 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
关于php - 从 php 和 sql 创建动态自动递增的 seo 友好 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15216201/