mod-rewrite help

They have: 426 posts

Joined: Feb 2005

Ok so i actually have not started to attempt this yet i just wanted to know if something is possible before i do start.

Im building a profile based system - just a directory full of user profiles. But the URL to their profile would be something like:

domain.com/profile.php?type=1&id=23

type is because i have 2 different types of users and the id is well the actual id of the user.

If i could somehow use php to convert the id into the actual username missing out the profile.php extention???

what i want is something like:

domain.com/profilename/

or even better:

profilename.domain.com

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

Your going to have to modify your php script to accept the user id. Once you do that, it's easy.

Quote:
RewriteEngine On
RewriteRule ^([A-Za-z0-9_\-]+)/ $path/to/script.php?user=$1 [L]

ILoveJackDaniels.com's cheat sheet is a nice reference for this.

They have: 426 posts

Joined: Feb 2005

I am accepting the user id - only the page url also has to specify the page it is loading up.

for instance: domain.com/index.php?action=2&id=4

the action specifies what page or action is taking place - in this case action 2 is a profile page and the id is the users id.

is there a way to rewrite the url so it undertands the action but does not show it, and renames the id to the users username and puts a backslash in front of it like this:

from:

domain.com/index.php?action=2&id=4

to:

domain.com/username

or would it have to be:

domain.com/profile/username

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.