phpisawesome Posted January 4, 2009 Share Posted January 4, 2009 How do you make it so after a user registers on your site they get there own profile like... www.test.com/username Almost like youtube? Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/ Share on other sites More sharing options...
darkfreaks Posted January 4, 2009 Share Posted January 4, 2009 mod_rewrite ;) Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729031 Share on other sites More sharing options...
phpisawesome Posted January 4, 2009 Author Share Posted January 4, 2009 What's that? Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729038 Share on other sites More sharing options...
DarkWater Posted January 4, 2009 Share Posted January 4, 2009 Well, firstly, you need a PHP script to handle grabbing the info. If it was, for example, named profile.php, it could conventionally be accessed like so: http://www.yoursite.com/profile.php?name=DarkWater After you get that sorted, you can go a step further and use an Apache module named mod_rewrite. It basically allows you to rewrite requests. You can use it to make "pretty URLs". It would allow you to rewrite: http://www.yoursite.com/DarkWater To: http://www.yoursite.com/profile.php?name=DarkWater The user would enter the first URL into their browser, and the server would actually serve back the second URL without the user needing to do anything. Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729041 Share on other sites More sharing options...
phpisawesome Posted January 4, 2009 Author Share Posted January 4, 2009 Can they just go directly to the 2nd url though? Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729048 Share on other sites More sharing options...
DarkWater Posted January 4, 2009 Share Posted January 4, 2009 Yeah, unless you don't want them to. Does it matter? Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729049 Share on other sites More sharing options...
phpisawesome Posted January 4, 2009 Author Share Posted January 4, 2009 I want them to know the 2nd url only. Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729052 Share on other sites More sharing options...
DarkWater Posted January 4, 2009 Share Posted January 4, 2009 Wait. By "the 2nd url", did you mean http://www.yoursite.com/DarkWater? If so, then they can absolutely go directly do it. In fact, that's the whole point of mod_rewrite. I thought you meant the second URL of the rewriting example, which is http://www.yoursite.com/profile.php?name=DarkWater. You had me confused there for a second, lol. Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729055 Share on other sites More sharing options...
phpisawesome Posted January 4, 2009 Author Share Posted January 4, 2009 Alright awesome thanks...any good tutorials on how to easily do this? Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729056 Share on other sites More sharing options...
premiso Posted January 4, 2009 Share Posted January 4, 2009 ummm.... http://www.google.com/search?hl=en&q=mod_rewrite+tutorial&btnG=Google+Search&aq=f&oq= Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729115 Share on other sites More sharing options...
npsari Posted January 4, 2009 Share Posted January 4, 2009 Easy You simply create a unique ID for each user Then you create one page which has all the codes Therefore, Lets say your site is http://www.example.com And the page is /user/ So, this link http://www.example.com/user/?ID=7663 Will open the user 7663 Obviously, you need to use like mySQL for all that stuff Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729120 Share on other sites More sharing options...
DarkWater Posted January 4, 2009 Share Posted January 4, 2009 @npsari: He wants to mod_rewrite by username, not just make a folder with an index.php that handles requests. That's like, makeshift mod_rewriting. =P Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729126 Share on other sites More sharing options...
premiso Posted January 4, 2009 Share Posted January 4, 2009 @npsari: He wants to mod_rewrite by username, not just make a folder with an index.php that handles requests. That's like, makeshift mod_rewriting. =P That and he probably wants it to be SEO Friendly. The ? is not very SEO friendly =) Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729127 Share on other sites More sharing options...
npsari Posted January 4, 2009 Share Posted January 4, 2009 Actually, i dont know what is SEO By the way, i didn't know my idea is not good... Because i have my website Yavrim and the profiles there are done like that (with user ids) I hope this is not bad Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729130 Share on other sites More sharing options...
premiso Posted January 4, 2009 Share Posted January 4, 2009 Search Engine Optimization... Basically using ? or & or = inside of URLs ranks lower than ones that do not, simply because search engines do not like to see them Also the id is numerical, also a downside cause 99% of searches contain words not numbers. Doing it with an actual username will yield higher results especially without the ? or & and = inside the query =) Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729139 Share on other sites More sharing options...
phpisawesome Posted January 4, 2009 Author Share Posted January 4, 2009 ya I just want to turn a www.test.com/profile.php?user_name=test to www.test.com/test Quote Link to comment https://forums.phpfreaks.com/topic/139385-register-help/#findComment-729198 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.