Jump to content

User pages


luke.browning

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.