vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Shorter Profile Url (https://vborg.vbsupport.ru/showthread.php?t=165986)

CallieJo 12-22-2007 10:00 PM

Shorter Profile Url
 
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: https://vborg.vbsupport.ru/showthrea...46#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):
Code:

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


Credits/References:
SitePoint
Vbulletin.com Thread
Zamurick X
Apache Module mod_rewrite

Zamurick X 12-23-2007 08:56 PM

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 12-23-2007 09:51 PM

Quote:

Originally Posted by Zamurick X (Post 1407831)
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 12-23-2007 10:53 PM

i' ll downloading this mod for research and use

CallieJo 12-23-2007 11:55 PM

Your welcome;)

aycan555 12-24-2007 12:40 AM

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 12-24-2007 03:45 AM

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 12-24-2007 09:33 AM

Not a modification, moved to articles section.

CallieJo 12-24-2007 05:41 PM

Quote:

Originally Posted by JawadIT (Post 1408092)
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:

Quote:

Originally Posted by http://www.htmlite.com/HTA003.php
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 [DATE]1198525319[/DATE] at [TIME]1198525319[/TIME] ---------------

Quote:

Originally Posted by Marco van Herwaarden (Post 1408238)
Not a modification, moved to articles section.

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

vuiveclub 12-25-2007 02:13 PM

How can I rewrite some unicode characters as "â ă â ã ạ ả á à ắ ầ " etc to "English character if I use this Rewrite?

Shaliza 12-26-2007 11:38 AM

Nice one. I'm going to try it. Much simpler than the other method that was posted.

Zamurick X 12-26-2007 09:15 PM

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:
Code:

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 12-29-2007 04:59 PM

Quote:

Originally Posted by Zamurick X (Post 1409710)
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:
Code:

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 02-03-2008 10:48 AM

Here is the code I'm currently using (I have other stuff in it but this will pertain to this article):
Code:

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:
Code:

<dd><a href="$prepared[profileurl]">$prepared[profileurl]</a></dd>
and change it to:
Code:

<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 02-21-2008 03:52 AM

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-03-2008 03:57 PM

Quote:

Originally Posted by cfitzarl (Post 1447862)
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 03-08-2008 04:15 PM

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 05-24-2008 05:44 AM

Quote:

Originally Posted by cheat-master30 (Post 1460123)
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 05-31-2008 07:57 PM

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 05-31-2008 09:00 PM

Quote:

Originally Posted by cheat-master30 (Post 1537280)
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 05-31-2008 10:21 PM

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 05-31-2008 11:12 PM

Quote:

Originally Posted by cheat-master30 (Post 1537371)
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 08-12-2008 12:46 PM

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 08-17-2008 12:00 AM

bump

Warlord 09-05-2008 05:12 PM

bump

Maddogz420 09-07-2008 10:16 PM

I'm curious about the %20 thing as well, names with spaces are causing a problem

camomouse 09-08-2008 06:48 AM

I can't even get users with spaces in there names to work.

Warlord 09-14-2008 02:04 AM

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

Warlord 09-24-2008 04:13 AM

bump

CLUB AMPLE 09-26-2008 12:25 AM

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 10-14-2008 08:03 PM

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:
https://vborg.vbsupport.ru/showthrea...rofile+rewrite

Does that work for anyone?

jdebler 04-12-2011 10:18 PM

I am using this and it works fine, here is what I have in my /blog/ directory .htaccess file:

Code:

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:

Code:

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 04-27-2011 10:01 AM

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 09-22-2013 08:47 PM

tried this and didn't work for vb4.2.1

Buzzle 01-18-2015 07:49 PM

Sorry for gravedigging but can someone convert this to nginx?

CallieJo 02-18-2015 08:18 PM

Quote:

Originally Posted by Buzzle (Post 2533222)
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.


All times are GMT. The time now is 01:55 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01416 seconds
  • Memory Usage 1,814KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (8)bbcode_code_printable
  • (10)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (36)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete