luke.browning Posted January 12, 2010 Share Posted January 12, 2010 Hi all, Im trying to make a system where users can access their profiles by going to a url with their username at the end, e.g. http://www.mysite.com/username. I'm not quite sure how I can dynamically show their profiles depending on the username at the end? Any help would be appreciated, Luke. Link to comment https://forums.phpfreaks.com/topic/188226-user-pages/ Share on other sites More sharing options...
jl5501 Posted January 12, 2010 Share Posted January 12, 2010 You would need to be using .htaccess to perform url rewriting. So where you might have a php page which can be accessed as profile.php and for a particular user it would be user.php?user=john, then you can write a rule which would take url of the form user_profile-john.html and convert it to the call to the php file. The actual structure of the incoming url and the rewritten url is variable, and would depend on what you want the initial urls to look like, and what the structure of your user profile information is. Best regards John Link to comment https://forums.phpfreaks.com/topic/188226-user-pages/#findComment-993728 Share on other sites More sharing options...
luke.browning Posted January 13, 2010 Author Share Posted January 13, 2010 Ahh ok. So, if I wanted to read the url in the form of: www.mysite.com/username What should I add to the .htaccess to change it to: www.mysite.com/user.php?user=username Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/188226-user-pages/#findComment-994102 Share on other sites More sharing options...
jl5501 Posted January 13, 2010 Share Posted January 13, 2010 Hi. You would be better off using a url of the form www.mysite.com/users/username to distinguish the user pages from other pages on your site. If you did that, then the rule would look like this RewriteRule ^users/(.*)$ www.mysite.com/user.php?user=$1 [L] Without the users/ it would be difficult to distinguish between a user profile url and other urls on the site. Of course, the directory users/ does not really exist, but the name is just in the url for the match logic Link to comment https://forums.phpfreaks.com/topic/188226-user-pages/#findComment-994117 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.