how to make user profiles be domain.com/username instead of domain.com/profile.php?user=username? [duplicate]

StackOverflow https://stackoverflow.com/questions/18863627

質問

I created a website where each member has a profile. I store their data in mysql database and I have a folder called pictures where I store members profile pictures with username as filename. each member's username is unique. I have one page called profile.php where I get user info using the php variable $_GET['user'] . the question is how do I make the user profile link be domain.com/username instead of domain.com/profile.php?user=username just like facebook,twitter and other websites ? can I do this without making a separate folder for each member? please help me because it will make easier access to profiles :) like when facebook used to have profiles url like facebook.com/profile?id=2659265892689356298 how did they change it to be facebook.com/usern.name ?

役に立ちましたか?

解決

The basis of your answer is in URL rewriting. You don't say which HTTP server you are using, but if it is Apache 2, you should look at the mod_rewrite documentation and come back with more specific questions regarding any problems (after searching for answers).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top