Jump to content

Twitter Like User Link


Recommended Posts

Hi my social networking site has users profiles like

 

domain.com/members.php?username=user

 

and i want

 

domian.com/user

 

or if easier

 

domain.com/user/user

 

but i have read many threads in here and tried out alot of the mod rewerites and none of them work, can someone help me please?

Link to comment
https://forums.phpfreaks.com/topic/236332-twitter-like-user-link/
Share on other sites

You can map domian.com/user/user to domain.com/members.php?username=user using

RewriteEngine On

RewriteRule user/([a-z0-9_-]+)/? members.php?user=$1 [NC,L]

 

In members.php you will need to modify your existing links so they adopt your new url format. Mod_rewrite will not do this for you. For example you may output your links like this

<a href="members.php?user=<?php echo $username; ?>"><?php echo $username; ?></a>

You'll need to change the above to

<a href="/user/<?php echo $username; ?>"><?php echo $username; ?></a>

Ah i missed that lol.

 

Anyway for this to only work with uses not images ect?

 

My icon on my heaer is called icon.png and when i go to a members profile the image no longer shows (just shows broken image) and when i view the image it takes me to /user/icon.png acting as if thats a profile

 

Edit..

 

Using ../ in front of the links on the page such as <a href="login.php">Login to ../login.php seems to work,. is that ok to use?

Because your url is now site.com/users/username for viewing a users profile. Your browser is thinking user/ is a directory. It is trying to load your links/images within this non existent directory. To prevent this start your url paths with a /

For example

<a href="/link.php">Link</a>

OR

<img src="/image.png" />

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.