PDA

View Full Version : Shorter Profile Url


CallieJo
23 Dec 2007, 22:00
What does it do?
It produces a short profile url like so: yourdomain.com/username

Do you guarantee it will work on my server?
No.

Will you support this if I cannot get it to work for me?
I cannot guarantee this will work for everyone and therefor I will not support this.

Will this work with usernames that have special characters or spaces in them?
I don't know. I have only tested it on my test forum with a few usernames that don't have special characters or spaces in them. If it works for you, please let others know.

How can I tell my members about the shorter profile url?
That is something you will need to figure out.
Or view my update post here to show it in their profiles: http://www.vbulletin.org/forum/showthread.php?p=1435246#post1435246

If this does not work for me, can you suggest another one?
VBseo
Zoints
Nuhit.com

Insert the following code in your .htaccess file (You might want to read the whole thread for other code examples that might work best for you):
RewriteEngine on
RewriteRule ^/?([a-zA-Z0-9]+)$ member.php?username=$1 [L]


Credits/References:
SitePoint (http://www.sitepoint.com/print/apache-mod_rewrite-examples)
Vbulletin.com Thread (http://www.vbulletin.com/forum/showthread.php?t=242089)
Zamurick X (http://www.vbulletin.org/forum/member.php?u=231291)
Apache Module mod_rewrite (http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html)

Zamurick X
23 Dec 2007, 22:56
This is great. I would like to add that you may want to remove the "/" from the .htaccess mod_rewrite. That will allow users who have their forums in another directory to use this. Because if I were to put the .htaccess in my /forum/ directory, and I went to "www.w.xyz/forum/username", it would most likely give me a 404, saying that "www.w.xys/member.php" does not exist. Thanks for the modification.

CallieJo
23 Dec 2007, 23:51
This is great. I would like to add that you may want to remove the "/" from the .htaccess mod_rewrite. That will allow users who have their forums in another directory to use this. Because if I were to put the .htaccess in my /forum/ directory, and I went to "www.w.xyz/forum/username", it would most likely give me a 404, saying that "www.w.xys/member.php" does not exist. Thanks for the modification.

Thank you. I've updated the code to reflect your suggestion and another change I found on the Apache site.

hocphp
24 Dec 2007, 00:53
i' ll downloading this mod for research and use

CallieJo
24 Dec 2007, 01:55
Your welcome;)

aycan555
24 Dec 2007, 02:40
but we got the foregn alfabets like my board there is turkish caracters user name; like these

Ayse
Ayşe

now both users url are going to be same, i am currently using it with siteurl/userid-username

JawadIT
24 Dec 2007, 05:45
hello
thanks for the mod
but the thing is that i am not knowing how and where to put that code...so could you please give us a brief explanation

thanks again

Marco van Herwaarden
24 Dec 2007, 11:33
Not a modification, moved to articles section.

CallieJo
24 Dec 2007, 19:41
hello
thanks for the mod
but the thing is that i am not knowing how and where to put that code...so could you please give us a brief explanation

thanks again

Place the code provided into your .htaccess file. If you do not have that file in the root of your forum, here is how to create one:

You don't need any special program or hardware to create an htaccess file. In fact, all you need is a regular, simple text editor such as Notepad.

Now the tricky part is saving the file. The htaccess file is a no-name filename with an eight letter extension.
".htaccess"

When you save files in a text editor, it will usually add a default extension to files, so you might end up with...
".htaccess.txt"

Here is how you fix this problem :
File
Save As...
In the FILE TYPE box, choose ALL FILES
In the FILE NAME box, type in ".htaccess"
And be sure you used quotes around the filename when you typed it in.

If that doesn't work, your FTP program should let you do a RENAME on a file to make it right.

--------------- Added 1198525319 at 1198525319 ---------------

Not a modification, moved to articles section.

Thank you. I wasn't sure where to place this.

vuiveclub
25 Dec 2007, 16:13
How can I rewrite some unicode characters as " ă ạ ả ắ ầ " etc to "English character if I use this Rewrite?

Shaliza
26 Dec 2007, 13:38
Nice one. I'm going to try it. Much simpler than the other method that was posted.

Zamurick X
26 Dec 2007, 23:15
Also does this regex support numbers? It appears it only supports a-z as the first character of the user name.

Try changing it to:

RewriteEngine on
RewriteRule ^/?([a-zA-Z0-9]+)$ member.php?username=$1 [L]


Although I'm not sure if it already does support all cases as well as numbers. Just a suggestion. Once again, thank you. :)

CallieJo
29 Dec 2007, 18:59
Also does this regex support numbers? It appears it only supports a-z as the first character of the user name.

Try changing it to:

RewriteEngine on
RewriteRule ^/?([a-zA-Z0-9]+)$ member.php?username=$1 [L]


Although I'm not sure if it already does support all cases as well as numbers. Just a suggestion. Once again, thank you. :)

Great suggestion! Thanks for helping out;) I've updated the article to reflect your suggestion.

CallieJo
03 Feb 2008, 12:48
Here is the code I'm currently using (I have other stuff in it but this will pertain to this article):
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^$ index.php
RewriteRule (^[-_A-Za-z0-9\ ]*$) member.php?&username=$1

I just wanted to make note that you must use a trailing slash at the end of your links to directories or you will get an error message saying that user does not exist. For example, if you have a gallery and you link to it like yoursite.com/gallery then you will need to change the url in your navigation to yoursite.com/gallery/ so the mod rewrite doesn't treat it like a username. Check your navigation to all areas of your site once you've used the mod rewrite code.

If you are using 3.7.0 beta 4 and want to change the url in member profiles to reflect their new profile url so they know what it is...

Edit the template "memberinfo_block_contactinfo" and find this code:
<dd><a href="$prepared[profileurl]">$prepared[profileurl]</a></dd>
and change it to:
<dd><a href="http://www.yoursite.com/$userinfo[username]">http://www.yoursite.com/$userinfo[username]</a></dd>
You will need to change yoursite.com to that of your forum. So if your forum is yoursite.net/forum or forums.yoursite.org or whatever, then be sure to change it as so.

cfitzarl
21 Feb 2008, 05:52
I would suggest using:

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

When you have (.*), that can stand for any letter, number, or symbol.

CallieJo
03 Mar 2008, 17:57
I would suggest using:

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

When you have (.*), that can stand for any letter, number, or symbol.

Thank you for contributing. Much appreciated.

cheat-master30
08 Mar 2008, 18:15
This works for most people on my forum, but not for any with special characters in their name, like myself. Any way to fix this?

NeverBored
24 May 2008, 07:44
This works for most people on my forum, but not for any with special characters in their name, like myself. Any way to fix this?
Anyone know how to fix this issue?

cheat-master30
31 May 2008, 21:57
I do, because one of the supporters of this, Zamurick, actually fixed the problem for me. I'll ask if it can be posted here.

NeverBored
31 May 2008, 23:00
I do, because one of the supporters of this, Zamurick, actually fixed the problem for me. I'll ask if it can be posted here.
Great, I hope so... It should be a simple fix from my understanding, though I have no idea how to do it.

cheat-master30
01 Jun 2008, 00:21
Here's what I used in the .htaccess file:

RewriteEngine on
RewriteBase /Board/upload/
RewriteRule ^u-(.+)/?$ member.php?username=$1 [L]

For you, it'd be like:

RewriteEngine on
RewriteBase [board directory starting with /]
RewriteRule ^u-(.+)/?$ member.php?username=$1 [L]

And you have the addresses as [yoursiteaddress.com]/[yourforumdirectory]/u-[username]

NeverBored
01 Jun 2008, 01:12
Here's what I used in the .htaccess file:

RewriteEngine on
RewriteBase /Board/upload/
RewriteRule ^u-(.+)/?$ member.php?username=$1 [L]

For you, it'd be like:

RewriteEngine on
RewriteBase [board directory starting with /]
RewriteRule ^u-(.+)/?$ member.php?username=$1 [L]

And you have the addresses as [yoursiteaddress.com]/[yourforumdirectory]/u-[username]

Thanks

Warlord
12 Aug 2008, 14:46
How can I make it so that usernames with spaces put an underscore between their first and last names instead of the %20 thing?

Warlord
17 Aug 2008, 02:00
bump

Warlord
05 Sep 2008, 19:12
bump

Maddogz420
08 Sep 2008, 00:16
I'm curious about the %20 thing as well, names with spaces are causing a problem

camomouse
08 Sep 2008, 08:48
I can't even get users with spaces in there names to work.

Warlord
14 Sep 2008, 04:04
Yeah, that's the same problem we're having. Anybody have a fix for this? I could really use this mod.

Warlord
24 Sep 2008, 06:13
bump

CLUB AMPLE
26 Sep 2008, 02:25
Is there anyone who is willing to write this hack in a simple foolproof version for all users? I'm willing to donate $50

jerx
14 Oct 2008, 22:03
Does anybody know which characters will cause problems with this mod? Spaces seem to be a big problem.

It looks like this similar mod does not have any problems with special characters and spaces:
http://www.vbulletin.org/forum/showthread.php?t=178929&highlight=profile+rewrite

Does that work for anyone?

jdebler
13 Apr 2011, 00:18
I am using this and it works fine, here is what I have in my /blog/ directory .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://www.mydomain.com/forums/blog.php?username=$1 [R]

But I am wondering if a directory is needed and if this cannot be done in the .htacces file in the main site directory.

I tinkered around with mine, and the closest I came to making it work was by adding the following code to my other lines of code in my .htaccess file in my main site directory:

redirectmatch 301 /blog(/.*)?$ http://www.mydomain.com/forums/blog.php?username=$1

The end result was close, but no cigar...

By going to
http://www.mydomain.com/blog/username
the end result is

http://www.mydomain.com/forums/blog.php?username=/username

That slash before the user name is what breaks it. Anyone know how to fix this?

bigs15
27 Apr 2011, 12:01
I am having a Problem.
When i go to.
http://mysite.com/username
the User id opens
but when i go to
http://mysite.com/member.php?u=2
then also member profile opens ..how do i remove this urls

http://mysite.com/member.php?u=2

fxdigi-cash
22 Sep 2013, 22:47
tried this and didn't work for vb4.2.1

Buzzle
18 Jan 2015, 21:49
Sorry for gravedigging but can someone convert this to nginx?

CallieJo
18 Feb 2015, 22:18
Sorry for gravedigging but can someone convert this to nginx?

Sorry, I'm not familiar with that. You might try a forum dedicated to nginx. They might be able to convert the rewrite rule to something you can use.