BrendanMullan Posted May 12, 2011 Share Posted May 12, 2011 Hi everone i am currently building a social network website, i have it mostly finished but one thing i am trying to do is instead of my members having the profile name of www.domain.com/ members.php?username=04836flfgkfifg84 for example, i want it to be like twitter or facebook where it is like www.facebook.com/Brendan Can someone help me out on doing this? Link to comment https://forums.phpfreaks.com/topic/236273-hide-file-name-like-social-networks/ Share on other sites More sharing options...
jonsjava Posted May 13, 2011 Share Posted May 13, 2011 check out Mod Rewrite Link to comment https://forums.phpfreaks.com/topic/236273-hide-file-name-like-social-networks/#findComment-1214773 Share on other sites More sharing options...
BrendanMullan Posted May 13, 2011 Author Share Posted May 13, 2011 Would i have to create a page for each user called there name? or can i rewrite the members.php?username=user to only show as /user Link to comment https://forums.phpfreaks.com/topic/236273-hide-file-name-like-social-networks/#findComment-1214777 Share on other sites More sharing options...
jonsjava Posted May 13, 2011 Share Posted May 13, 2011 You can have it set so members.php?username=user shows up as /user You can even have it set so members.php?username=user shows up as /hidden_files/users/u/user how ever you like. Just ask for help in the topic I linked to. Link to comment https://forums.phpfreaks.com/topic/236273-hide-file-name-like-social-networks/#findComment-1214778 Share on other sites More sharing options...
BrendanMullan Posted May 13, 2011 Author Share Posted May 13, 2011 Looking at a lot of the threads there i have tried a few ways and with no luck, i seen there is a way with php maybe, i have the username in the database that i want for the url so www.domain.com/username, anyone know a way i can grab the users username and replace the members.php?username=user with it? Link to comment https://forums.phpfreaks.com/topic/236273-hide-file-name-like-social-networks/#findComment-1214787 Share on other sites More sharing options...
jonsjava Posted May 13, 2011 Share Posted May 13, 2011 You cannot do it with pure php. You must set up a mod_rewrite rule. That is the only way to re-write the file name. Link to comment https://forums.phpfreaks.com/topic/236273-hide-file-name-like-social-networks/#findComment-1214789 Share on other sites More sharing options...
BrendanMullan Posted May 13, 2011 Author Share Posted May 13, 2011 I have tried like this RewriteEngine On RewriteRule ^/(.+)$ /members.php?username=$1 does nothing RewriteEngine on RewriteBase / RewriteRule ^([a-zA-Z0-9]+) members.php?username=$1 RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ $2.php?username=$1 takes out the members.php but stays on members page cant go anywhere else Link to comment https://forums.phpfreaks.com/topic/236273-hide-file-name-like-social-networks/#findComment-1214795 Share on other sites More sharing options...
jonsjava Posted May 13, 2011 Share Posted May 13, 2011 change your base to RewriteBase /members.php Link to comment https://forums.phpfreaks.com/topic/236273-hide-file-name-like-social-networks/#findComment-1214797 Share on other sites More sharing options...
BrendanMullan Posted May 13, 2011 Author Share Posted May 13, 2011 Still cant move to any page Link to comment https://forums.phpfreaks.com/topic/236273-hide-file-name-like-social-networks/#findComment-1214806 Share on other sites More sharing options...
jonsjava Posted May 13, 2011 Share Posted May 13, 2011 I know the basics of mod_rewrite. I would recommend that you read up on the topic, or ask the proper forum. We won't do everything for you. Link to comment https://forums.phpfreaks.com/topic/236273-hide-file-name-like-social-networks/#findComment-1214822 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.