codexx Posted January 29, 2007 Share Posted January 29, 2007 Hello Everyone,I've made a small community for a group of schools around me and have run into a road block. I'd like to make it like mySpace where users can create a "url" type username ie mysite.com/codexx .I also don't mind if it is subdomains. I tried creating a wildcard and then forwarding to my homepage and then decode the url and forward in a header but couldn't get it working correctly.My main problem is i'm using cpanel, but I do have admin and root access so can modify apache. Quote Link to comment https://forums.phpfreaks.com/topic/36226-solved-mysitecomusername-redirects-in-php/ Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 Google: mod_rewrite Quote Link to comment https://forums.phpfreaks.com/topic/36226-solved-mysitecomusername-redirects-in-php/#findComment-172138 Share on other sites More sharing options...
cmgmyr Posted January 29, 2007 Share Posted January 29, 2007 I have the same type of set up for one of my sites - syracusebands.net my user profile page is profile.php my .htaccess[code]RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^([^/\.]+)/?$ profile.php?moduser=$1 [L][/code]I'm using the moduser as the "username" at the end of the urlOn the top of my profile.php page I have: [code]if(isset($moduser)){ $query = "SELECT * FROM users WHERE moduser = \"$moduser\""; $result = mysql_query($query) or die('Query mod failed: ' . mysql_error()); $userid = mysql_result($result, 0, 'userid'); }[/code]and that passes the userid down through the rest of the script for the other queries.So my page... www.syracusebands.net/admin acts the same as www.syracusebands.net/profile.php?userid=1I hope this helps you out.-Chris Quote Link to comment https://forums.phpfreaks.com/topic/36226-solved-mysitecomusername-redirects-in-php/#findComment-172146 Share on other sites More sharing options...
codexx Posted January 30, 2007 Author Share Posted January 30, 2007 Thank you so much :). Works great!!! I've spent almost 3 weeks playing around with this and finally its working.Again, thank you! Quote Link to comment https://forums.phpfreaks.com/topic/36226-solved-mysitecomusername-redirects-in-php/#findComment-172455 Share on other sites More sharing options...
cmgmyr Posted January 30, 2007 Share Posted January 30, 2007 No problem! glad I could help Quote Link to comment https://forums.phpfreaks.com/topic/36226-solved-mysitecomusername-redirects-in-php/#findComment-172726 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.