-1

So I'm build a site that has user profiles. what I want to do is grab from the database the users username and display it in the url, so something like this:

example.com/profile/derrick in stead of showing (example.com/profile.php?id=123)

I always want to do this with the photos that they upload as well. I want to grab the title of the photo and make it the url:

example.com/shots/my-photo-title-here in stead of showing (example.com/shots.php?id=13)

If anyone has a good tutorial out there, or script they wrote themselves I would be very happy to know about it. Thanks!

4

3 回答 3

3

利用: $urlarray = explode("/", $_SERVER['REQUEST_URI']);

示例:网址:www.mysite.com/this/is/it

$urlarray[1] will by this
$urlarray[2] will by is
$urlarray[3] will by it

从那里你可以试试看:)

于 2012-02-21T16:31:49.997 回答
0

这是一个关于干净网址的非常好的教程:

清理网址

我发现更好的方法之一确实有效。祝你好运

于 2011-05-27T20:22:23.410 回答
0

有一个不错的干净 URL 生成器:http ://www.generateit.net/mod-rewrite/ 。

于 2013-04-12T13:37:35.803 回答