url 屏蔽 mod_rewrite
我正在缓慢但坚定地学习 php,到目前为止一切都很顺利。
我希望进行网址重写,我的数据库相对深入,典型的网址如下所示:
players.php?position=1&teamid=4&playerid=129
基本上我想返回 /Defender/Arsenal/Thomas-Vermaelen / 基本上是与数据库中的 ID 相关联的名称。这一页面会生成许多不同的页面,我想练习如何使用 URL 中的名称而不是 ID 号。
我 99% 确定这可以完成,因为我一直在详细查看 Joomla CMS 系统,并且想知道是否有人可以帮助阐明这一点?
预先感谢
理查德:)
I am slowly but surely learning php, and all is going well up until now.
I am looking to do a url rewrite, my DB is relatively indepth and a typical url would look like:
players.php?position=1&teamid=4&playerid=129
basically i want to return /Defender/Arsenal/Thomas-Vermaelen/ which are basically the names associated with the ID's in the database. This one page generates lots of different pages and I wanted to workout how to use the name in the URL instead of the ID number.
Im 99% sure this can be done as I have been looking in detail at the Joomla CMS system, and wondered if anyone could help shed some light on this please?
Thanks in advance
Richard :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为最简单的方法是将请求的 URI
/Defender/Arsenal/Thomas-Vermaelen/
映射到/players.php?position=Defender&teamid=Arsenal&playerid=Thomas-Vermaelen
:然后在 PHP 脚本中,您可以检查参数值是数字还是字母,并在后者的情况下获取数字 ID。
I think the easiest would be to simply map the requested URI
/Defender/Arsenal/Thomas-Vermaelen/
onto/players.php?position=Defender&teamid=Arsenal&playerid=Thomas-Vermaelen
:Then in you PHP script you can check whether the parameter value was numeric or alphabetic and fetch the the numeric ID in case of the latter.