Sebastian
Sebastian

Reputation: 3628

Generating a profile page for a user upon registration

I'm currently working on a site that needs to generate a profile page for a user upon registration. I want the page to be in the format www.domain.com/username. Is it possible to do this without creating subdomains?

Upvotes: 0

Views: 394

Answers (2)

M.M.H.Masud
M.M.H.Masud

Reputation: 329

Yes you can do this easily using routing rules either in .htaccess file. If you use Codeigniter or zend framework you can do that more easily.

IN Codeigniter:

make a controller: user make a method: profile take a parameter: $userName

public function profile($userName){ ............................... }

got to route.php file in application/config/ folder

$route['(a-zA-Z0-9)'] = 'user/profile/$1';

So if you type http://www.domain.com/testuser it will hit to your User controller's profile method and pass the username as parameter to that method as $userName.

That's all...

Upvotes: 0

piddl0r
piddl0r

Reputation: 2449

Yes it is possible. Create a .htaccess file and use mod_rewrite to route the request.

Apache - mod_rewrite

mod_rewrite cheatsheet

Upvotes: 1

Related Questions