views:

19

answers:

3

Hi All,

I am building an application for my client and I am not using any frameworks . Question came up when building viewing user profile

My client wants to see the user profile URL like

mywebsite.com/Johnd - should give Johnd profile mywebsite.com/KJohns - should give KJohns profile

I have implemented URL mapping like http://mywebsite.com/viewprofile.php?id=Johnd . But I am not sure how to map viewprofile.php?id=Johnd to just 'Johnd' .

Could some body please advise ?

Thanks for your help Regards Bujji

A: 

mod_rewrite might be what you're looking for (if you're running apache at least). Have a look at http://www.workingwith.me.uk/articles/scripting/mod_rewrite for a brief intro/tutorial to see if that's the type of thing you need.

Thanks for your response
Bujji
A: 

use modrewrite and ataccess file

there is a lot of tutorials on the net called pretty url, check this one for ex.:

http://wettone.com/code/clean-urls

Dobiatowski
Thanks for your response
Bujji
A: 

If you are using Apache, adding a rule to your .htaccess file that says:

RewriteRule .*/profiles/(.*) viewprofile.php?id=$1 [NC, L]

Will let people access http://mywebsite.com/viewprofile.php?id=Johnd through http://mywebsite.com/profiles/Johnd

Alternately, if you wanted to use PHP to do this, you could map all your requests to a single file and if the request is not your list of urls, assume it's a user and route it there. (Take a look at the code for Tweetable MVC for the basics.)

Sean Vieira
Thanks for your response
Bujji