开发者

Any easy, noncluttering way to set up "mydomain.com/username" using PHP?

Simply put, when a user wants people to be able to go to their profile, we want them to be able to just say go to mydomain.com/username. The real user page would be at something like mydomain.com/users/page.php?id=1325 which doesn't really help users.

The problem: I've been doing PHP for some time, and have never had the need to do this. I don'开发者_运维百科t have a clue where to even start? I wouldn't want to do something as naive as just creating actual folders with redirects in them or something....

Can anybody tell me how to go about this in php?

Y'all are the greatest!


Provided you are on an apache server look up .htaccess and mod_rewrite, it all happens outside of PHP.

Example for your .htaccess:

RewriteEngine on
RewriteRule ^([0-9a-zA-Z]+)([\/]?)$ /user/profile.php?name=$1 [L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜