如何通过URL路径传递参数
有一些网站通过 URL 发送参数,如下所示:
www.site.com/user/12345678
(就像stackoverflow一样)
有人可以就这个论点进行一些讲座吗?我想了解它是如何工作的并将其实现到我的 php 平台中。
There are some sites that send parameters via URL like this:
www.site.com/user/12345678
(just like stackoverflow does)
Can someone give some lectures about the argument? I'd like to learn how this works and implement this into my php platform.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这些“漂亮的网址”是通过使用 mod_rewrite 来完成的。
任何好的框架都会实现此功能(通常称为路由),并且在 MVC 架构中将提供诸如 http://www.mysite.com/controller/view/param1/param2...等。
网上有大量关于“mod 重写教程”的教程,例如 这个。
Those "pretty urls" are accomplished with the use of mod_rewrite.
Any good framework will have this implemented (usually called routes) and in MVC architecture will provide links such as http://www.mysite.com/controller/view/param1/param2...etc.
There are tons of tutorials on the web for "mod rewrite tutorial" such as this one.
快速回答:Google 关键字
mod_rewrite
和.htaccess
结果示例:http: //www.easymodrewrite.com/
Quick answered: Google keywords
mod_rewrite
and.htaccess
Example result: http://www.easymodrewrite.com/
这称为“URL 重定向”。这样做通常是为了使 URL 对用户和 SEO 友好。您可以找到示例/脚本来重定向您的 URL:
http://www.sitepoint.com/指南 url 重写/
This is called "URL Redirection". This is usually done to make URLs user and SEO friendly. You can find the examples/scripts to redirect your URL:
http://www.sitepoint.com/guide-url-rewriting/