PDA

View Full Version : Rewrite URL to Profil Page (using mod_rewrite)


suryoyena
05-23-2008, 03:34 PM
Hi Community,

I'm thinking about a modification, that let the user choose a favourite word in the user cp, which will build a URL.

An example:
My User ID is 45 and my choosen word is "my-world".
mydomain.com/my-world have to redirect to my profilpage at mydomain.com/member.php&u=45

Maybe you are interested in this, too :)

Greets 2.0 from Germany

Chris

GameWizard
05-24-2008, 02:34 AM
Although I believe this is possible, the only issue is that you will need to manually code in a way to prevent duplicate words. As if two people chose the same word, it will mess things up and currently I'm not aware of any hack that checks for duplicate entries.

Here is the code that you can use in your .htaccess file in order to convert links:

RewriteEngine on
Options +FollowSymLinks
RewriteRule ^users/(.*)/?$ member.php?username=$1 [L]

The code above works as follows, say your username is "Username", if you visit http://yourdomain.com/forum/users/Username, it will automatically redirect you to appropriate userid and display the profile.

There are some other versions of the code above that allow you to use more symbols in the name, as some names include things like (){}[]!@#$ and other weird symbols which may not be parsed correctly.

ther users/ part can be changed to anything you wish depending on the prefix you'd like. It doesn't necesserily need to be in a folder, you could also use a character if you wish such as ~Username, or u=Username. Whatever is easier for you.