-1

我想建立一个系统,当有人想要搜索注册用户时,他/她只需从网站 url 搜索。它有点令人困惑..我举个例子:在 facebook.com 中,当输入http://facebook.com/john_corner时,会显示注册用户 john_corner 的个人资料。我怎样才能在我的网站上得到这个?请给我一个方向怎么办?非常感谢任何帮助、代码、建议和有用的链接。

提前致谢。

4

2 回答 2

0

您正在寻找的是 URL rewriting

大多数网络服务器或多或少都支持它,但是 apache 和 nginx 支持它。

如果您使用的是 apache,请查看mod_rewrite文档:http ://httpd.apache.org/docs/current/mod/mod_rewrite.html

简短说明:您设置规则以映射readable urls到现有文件,例如,yoursite.com/(.*) 到 index.php?username=$1。

于 2012-08-21T18:20:50.953 回答
0

你可以通过重写来做到这一点

RewriteEngine       On
RewriteRule   ^(.*)?/([A-Za-z0-9-]+)   http://%{HTTP_HOST}/index.php?username=$1 [R]

您也可以通过这种方式将短网址转换为完整网址。

对于 apache mod_rewrite

对于 IIS URL 重写模块

于 2012-08-21T18:26:29.390 回答