Jump to content

[SOLVED] mysite.com/username.. Redirects in PHP?


codexx

Recommended Posts

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.
Link to comment
Share on other sites

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  on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\.]+)/?$ profile.php?moduser=$1 [L][/code]

I'm using the moduser as the "username" at the end of the url

On 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=1

I hope this helps you out.

-Chris
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.