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

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.