不同的URL地址结尾,用于将用户定向到同一页面但具有动态内容

I have a WordPress based site with a custom social network functionality that I wrote using php and jQuery.

Right now when my users sign up for an account, WordPress automatically creates a page for them with the address www.mysite.com/members/username where 'username' is their unique URL address. This way each member has their own page that they can access with their unique URL address.

The problem is that as my members base is growing, I am realizing that I will have thousands of profile pages created for each user and this can become a big mess.

So I was thinking to simplify this process and instead of creating a WordPress Page for each user have one profile WordPress page that dynamically loads its contents based on which 'username' ending is found in the URL address.

Is this possible? and if so how can I get started?

Thanks for all your help in advance.

Using Wordpress:

Create a new rewrite rule for /members/username

function members_rewrite_rules()
{
  add_rewrite_rule('members/(.+)/?$', 'index.php?pagename=members&username=$matches[1]', 'top');
}
add_action( 'init', 'members_rewrite_rules' );

Add the username variable to $wp_query.

function members_query_vars($query_vars)
{
  $query_vars[] = 'username';
  return $query_vars;
}
add_filter('query_vars', 'members_query_vars');

Then in your 'members' template page you can grab the query var and use it to load the member profile:

<?php
get_header();
$username = get_query_var('username');
// load the user details using $username
get_footer();
?>

You want to look at URL rewriting.

# .htaccess
RewriteRule ^members/([0-9a-z]+)/?$ ?members&username=$1 [NC,L]

// members.php
$username = $_GET['username'];
$result = mysql_query("SELECT age, location FROM members WHERE username = '$username'");
$data = mysql_fetch_assoc($result);

echo "age: ".$data['age'];
echo "location: ".$data['location'];

well, something like that. and all users are using the same page(file) members.php. you just load data into it and then print out details.