PDA

View Full Version : User MOD Rewrite


altsounds
05-22-2005, 10:00 PM
This is a pretty simple hack but is designed so that you can access members profiles quickly and / or your members can have an easy link to pass around for their user profile.

STEP 1:

If you don't have one already create a file named .htaccess in your forums root directory.

STEP 2:

Paste the following code within that file:

## Altsounds.com Member re-write Hack Version1
## All music fans should check out altsounds.com for lots of free music to listen to!!

# turn the Apache MOD_REWRITE engine on
RewriteEngine On

# this first rule will catch the "blank" entry into the
# Forums directory, taking the user to the main forum page - change as appropriate
RewriteRule ^$ hangout.php

# this next entry will catch everything else and pass
# it to the member.php engine for processing in
# the "member" section
RewriteRule (^[-_A-Za-z0-9\ ]*$) member.php?&username=$1

That's it! My main forum page is hangout.php. So you should change that within the code above to whatever your forum main page is (usually index.php).

Now all your members links to their profile is {link to forum}/{username} or {link to forum}/{userid} e.g. in my websites case http://hangout.altsounds.com/altsounds or will take you directly to the username "altsounds" user profile. If no profile is available (i.e. a member is not registered) you will get the appropriate error message.

Simple but cool. Hope you all enjoy.

Paul_d_g
05-23-2005, 08:03 PM
Screenshots?

altsounds
05-23-2005, 08:04 PM
Well there aren't really any because all this is doing is allowing you to type in username after your forum address to go directly to a users profile making it easy to link to and lookup users profiles.

Rather than having to type in {forumaddress}/member.php?username={username}. Now you can just type {forumname}/{username}.

nexialys
05-23-2005, 08:10 PM
NOTA: you need MOD_REWRITE to be activated in your Apache installation... not all Hosts permit this... verify before making any complain here that it's not working properly...

altsounds
05-23-2005, 08:15 PM
Yeah thanks nexialys for that good point. If this hack doesn't work for you it means that you don't have MOD_REWRITE activated in your Apache installation and the hack won't work period.

Lionel
05-23-2005, 09:36 PM
Problem with this hack, everything under is subjected to it, such as /forums/gallery tells you user has not registered

altsounds
05-23-2005, 09:43 PM
Not if you place the trailing slash at the end of the directory e.g. /forums/gallery/ will still take you to gallery. No slash takes you to the user profile trailing slash takes you to the driectory you want and, if you link directly to a PHP file that works fine too.

Lionel
05-23-2005, 10:00 PM
ok, thanks. I will put the trailing slash in the links because I like your hack.

nexialys
05-23-2005, 10:39 PM
a little modif here, so everyone is happy...:

ifyou want your users to be located also by their userid instead of just their username, change the last line with:
RewriteRule (^[-_A-Za-z\ ]*$) member.php?username=$1
RewriteRule (^[-_0-9\ ]*$) member.php?userid=$1

altsounds
05-24-2005, 01:49 AM
ok, thanks. I will put the trailing slash in the links because I like your hack.

You should always make sure you put the trailing slashes in just to make sure ;). If you installed the hack please click install as this is my first hack and I would love to see how many people actually end up using this hack.

altsounds
05-24-2005, 01:52 AM
a little modif here, so everyone is happy...:

ifyou want your users to be located also by their userid instead of just their username, change the last line with:
RewriteRule (^[-_A-Za-z\ ]*$) member.php?username=$1
RewriteRule (^[-_0-9\ ]*$) member.php?userid=$1

Nexialys thanks again for making sure everyone is happy. I appreciate that. Follow Nexialysis' mod of this hack if you want to do it by userid too.

Lionel
05-24-2005, 02:03 AM
I have the guestbook/homepage hack installed, the modified version that displays it on a separate page; so what I did was a htaccess from root to display members webpage and another one at forum root to display the profile.

I learn something today and I started to change all my directory links to reflect the trailing slash.

ericgtr
05-24-2005, 02:11 AM
altsounds, nice mod! I also really dig your site, it looks like you are using jamroom? I wrote up a little something so your vb members can add their jamroom album to under their avatar in the postbit, here's the link to it on the jamroom site http://www.jamroom.net/phpBB2/viewtopic.php?t=2910

altsounds
05-24-2005, 01:02 PM
Eric cool MOD, I will be using this for sure.

Boofo
05-25-2005, 01:27 PM
Will they still get the appropriate error message if they are now allowed to view profiles, like Guests, or will this bypass that?

altsounds
05-26-2005, 06:10 PM
Will they still get the appropriate error message if they are now allowed to view profiles, like Guests, or will this bypass that?

Haven't tested this but you should still get the same message regardless of whether or not you are a guest or a registered visitor. Basically letting you know that the member doesn't exist.

T3MEDIA
05-26-2005, 06:48 PM
They get the error I just wish this worked more smoothly. A lot of links come up dead after doing this.


isnt there a wildcard version to this that makes your site a subdomain?

username.yoursite.com
?

altsounds
05-27-2005, 05:20 PM
As discussed earlier, if your directory links have a trailing / you should have no problem, you should be putting / into links that are directories anyway.

Hope that helped?

Lizard King
05-27-2005, 08:09 PM
Working pretty good thanks :)

Jolten
05-28-2005, 12:20 AM
This is sort of overkill. There are two ways to access user profiles built in, ID and username.

the parameter for id is member.php?u=Userid
the parameter for username is member.php?getinfo&username=username

You do not need to mod rewrite it.

altsounds
05-31-2005, 05:13 PM
This is sort of overkill. There are two ways to access user profiles built in, ID and username.

the parameter for id is member.php?u=Userid
the parameter for username is member.php?getinfo&username=username

You do not need to mod rewrite it.

There is a lot of call for people just be able to do sitename/username . You have to understand that most users of websites want to direct link to their profiles but have no idea how. This little hack makes people linking to their profiles and sharing it with friends that much easier.

blueuniverse
06-20-2005, 09:24 AM
Just to make things even easier for the members (something that is needed on my boards, you can add a link to their profile on the main usercp page). This is what suited me best, but I thought it might be wortwhile posting it here so some of you guys could possibly make use of it.

Anyway, it's just a simple template edit. Go to the template USERCP. Then do the following.

Find

<!-- ############## SUBSCRIBED THREADS ############## -->

ABOVE add

<!-- Start modrewrite usercp add - by ed -->
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tbody id="collapseobj_usercp_proflink" style="$vbcollapse[collapseobj_usercp_proflink]">
<tr>
<td class="alt1"><strong>Link to profile: </strong><a href="$vboptions[bburl]/$bbuserinfo[username]">$vboptions[bburl]/$bbuserinfo[username]</a></td>
</tr>
</tbody>
</table>
<br />
<!-- End modrewrite usercp add - by ed -->

Note - edited it to add the $vboptions[bburl] suggested by nexialys. Thanks. :)

Also, it should be noted that the bit of code there only works when you do the username mod_rewrite. If you did the userid mod_rewrite then replace $bbuserinfo[username] with $bbuserinfo[userid]. I haven't tested that, but I'm pretty sure it should work.

altsounds
06-21-2005, 02:06 PM
Nice add on ed. I have already done this on my site but for those that haven't this is of course beneficial.

nexialys
06-21-2005, 02:12 PM
YOURBOARDURLHERE can be replaced by : $vboptions[bburl] ... that's the goal of that variable!

blueuniverse
06-21-2005, 06:05 PM
Ok, I edited it to include that. Thanks :D

amykhar
07-10-2005, 02:34 PM
There's a bug, gang. The username is working. The userid isn't. It's going to a user not found page because it can't find a user with a number name.

Amy

altsounds
07-15-2005, 08:05 PM
Thanks for letting me know Amy. The userid thing was added by another user, not me. My original was specifically so that you could do username.

Kirk Y
07-20-2005, 02:26 AM
The UserID works for me, as does the member name. This is very neat.. the only thing I didn't like was the trailing slash, but I'll just get used to it!

@Amy: Could it be something with your mod_rewrite?

KTBleeding
07-20-2005, 03:08 AM
Pretty cool mod..

I did notice a problem though. If a user has a "." in their name, it will not work. I'm pretty sure this is an obvious error..

Would there happen to be a fix for this at all?

Kirk Y
07-20-2005, 03:58 AM
I also noticed that if the user has a space in their name, it doesn't work. A %20 is added in its place... and won't work.

KTBleeding
07-20-2005, 04:39 AM
I also noticed that if the user has a space in their name, it doesn't work. A %20 is added in its place... and won't work.
I can't confirm this: The %20 works just fine for me so far.

loftyasianz
07-25-2005, 09:49 PM
this hack is very usefule thank you. it will work PERFECTLY when vBSpace comes out. where the users can have a http://www.yoursite.com/username. awesome!

vbspace here -> https://vborg.vbsupport.ru/showthread.php?t=82930

edit: one of my members noticed something after i installed. i have vba cmps installed on my forum so i put the .htaccess file in the root directory, edited hangout.php to forums/index.php and members.php to forums/members.php so users can have www.mysite.com/username. but when one of my members was playing around with it he noticed that if you do so it goes to the user's profile but then all of the images that are comming from image.php are comming up broken. does anyone know how to get around this?

thanks in advance.

Q-v-n-s-Q
07-28-2005, 05:05 PM
this hack is very usefule thank you. it will work PERFECTLY when vBSpace comes out. where the users can have a http://www.yoursite.com/username. awesome!

vbspace here -> https://vborg.vbsupport.ru/showthread.php?t=82930

edit: one of my members noticed something after i installed. i have vba cmps installed on my forum so i put the .htaccess file in the root directory, edited hangout.php to forums/index.php and members.php to forums/members.php so users can have www.mysite.com/username. but when one of my members was playing around with it he noticed that if you do so it goes to the user's profile but then all of the images that are comming from image.php are comming up broken. does anyone know how to get around this?

thanks in advance.


* BUMP

loftyasianz
07-28-2005, 05:17 PM
thanks ricky. lol i guess you're having the same problem too.

poetic
08-08-2005, 03:09 PM
what if they have different characters than "(^[-_A-Za-z0-9\ ]*$)"

how can we make it so people with all different characters can use it

deathemperor
10-13-2005, 02:50 PM
great hack.

how about if the link site.com/usernamewhatever doesn't return a match username it will then check if there is a folder with the name usernamewhatever ?

well I think it's ok without that

/me clicks install

altsounds
11-11-2005, 05:15 AM
Pretty cool mod..

I did notice a problem though. If a user has a "." in their name, it will not work. I'm pretty sure this is an obvious error..

Would there happen to be a fix for this at all?

Yes, it is recommended tha you run another hack on here for no Special Characters in usernames. Add that hack to stop your users being allowed to add special characters to their usernames. This is pretty much an essential addon hack needed to get the full functionality of this and so you get no 404 erros. I will see if I can find it and post the link here. If anyone finds it b4 me feel free to post it here.

altsounds
11-11-2005, 05:19 AM
This would not be due to the hack. MOD rewrite does nothign to your code it meerly takes a string and based on the criteria (or lack thereof) returns a users profile or appropriate error message.

You might want to try (don't know if this will do anything) to put the links as full URLs e.g. http://blahblahblah/forums/member.php.

Other than that I'm not sure why this may have happened and as I said above this hack does not change your vbulletin setup or configuration at all.

this hack is very usefule thank you. it will work PERFECTLY when vBSpace comes out. where the users can have a http://www.yoursite.com/username. awesome!

vbspace here -> https://vborg.vbsupport.ru/showthread.php?t=82930

edit: one of my members noticed something after i installed. i have vba cmps installed on my forum so i put the .htaccess file in the root directory, edited hangout.php to forums/index.php and members.php to forums/members.php so users can have www.mysite.com/username. but when one of my members was playing around with it he noticed that if you do so it goes to the user's profile but then all of the images that are comming from image.php are comming up broken. does anyone know how to get around this?

thanks in advance.

vau7
11-11-2005, 06:18 AM
Could work for 3.5, or?

Inferno Dragon
12-14-2005, 02:55 PM
^ yes..It will work! I am sure about it :D

Lpspider
01-03-2006, 01:13 AM
Yup. Works perfectly.

Lpspider
01-04-2006, 12:40 AM
^ doesn't work perfectly. It does sometimes - but it seems that it messed up my main url. www.mysite.com didn't work, whereas www.mysite.com/username or www.mysite.com/index.php did.

Any idea what caused this and if there's a version for 3.5?

EDIT: spoke too soon. I didn't rename it to index.php - however, when I type in my URL it doesn't take me to the homepage, but rather to a page listing the directories, etc. Don't know why.

TunerNetwork
02-12-2006, 03:46 PM
k, works pretty good for me. Nice add on. Now...is there a way that we can have it so on the user's profile page, it displays what their profile link would be?

This way they can just copy that, add to their signatures on the site or on other sites etc. Kinda help people see that, and check out their profiles, and pretty much getting them to your site.

http://www.tunernetwork.com/forum/zazza%20ceo

Thats mine, I started working on the custom profile page lastnight, so not done all the way, it's slowly coming together.

TunerNetwork
02-12-2006, 06:29 PM
I think if i do a $username code, ill give it a whirl and let you know how i make out

The Chief
04-23-2006, 03:37 AM
Have anybody gotten the solution for this on a lighttpd working server?

dinodonk
06-23-2006, 05:10 PM
it's working thanks!!
can i change www.domain.com/forum/username to profile.domain.com/username while forum url is still www.domain.com/forum ???

TIA

Majidm
10-19-2006, 01:35 AM
Any way to make it convert periods to spaces? Would be better for linking members with spaces...

i.e http://www.mysite.com/User.with.Spaces goes to the member "User with Spaces"

thenetbox
10-25-2006, 01:31 AM
Hi, Would this work for 3.6.2 as well? thanks

bo0oost
12-13-2006, 02:57 AM
I'm running windows and PHP 4.4.4, can I get this working on my system? Also VB 3.6

thanks

|Jordan|
03-12-2007, 03:05 AM
How do you make all links on the page use this system instead of the default vb way?