MyBB Community Forums

Full Version: Your own short URLs
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hi!

If you are using Apache you can create your own short URLs for MyBB (nginx users look here: http://community.mybb.com/thread-85532-p...#pid655723). Just add the following line to your MyBB .htaccess file:

RedirectMatch permanent ^/p([0-9]+)$ http://www.example.com/showthread.php?pid=$1#pid$1
RedirectMatch permanent ^/t([0-9]+)$ http://www.example.com/showthread.php?tid=$1
RedirectMatch permanent ^/f([0-9]+)$ http://www.example.com/forumdisplay.php?fid=$1

It's a very simple redirection but useful on Twitter or Facebook. Just use p(ost), t(hread) or f(orum) and the ID you want to redirect.

Live demo:

http://phurl.de/p7832 -> redirects to a post
http://phurl.de/t1294 -> redirects to a thread
http://phurl.de/f31 -> redirects to a forum
Of course, this also works with user URLs, event URLs and calender URLs:

RedirectMatch permanent ^/u([0-9]+)$ http://www.example.com/member.php?action=profile\&uid=$1
RedirectMatch permanent ^/e([0-9]+)$ http://www.example.com/calendar.php?action=event\&eid=$1
RedirectMatch permanent ^/c([0-9]+)$ http://www.example.com/calendar.php?calendar=$1

Please note the backslash before ampersands.
Nice , thank you for cool sharing
Thanks for the tutorial Smile

However, the links has to built manually.
How to use this with Google SEO plugin ???
There's a setting which redirects old URLs to new URLs.

Then it would redirect everything like so:

1. http://example.com/t100
2. http://example.com/showthread.php?tid=100
3. http://example.com/Thread-Title
Thanks for this tutorial.Big Grin
I just have a question. What if i change RedirectMatch permanent to RewriteRule? (RewriteEngine on of course)
Will my links become like that?
(2011-01-05, 03:30 PM)One-Two Wrote: [ -> ]What if i change RedirectMatch permanent to RewriteRule? (RewriteEngine on of course)

Works the same way. But why do you want to convert this simple RedirectMatch to a more complex RewriteRule?
Thank you Smile
Hint: Of course you can use the redirects on a shorter domain than your MyBB URL (as you can see in the examples in the first post).
Nginx Version:
#Short URLs:

rewrite ^/t([0-9]+)$ /thread-$1.html permanent;
rewrite ^/p-([0-9]+)$ /post-$1.html permanent;
rewrite ^/u-([0-9]+)$ /user-$1.html permanent;
rewrite ^/f([0-9]+)$ /forum-$1.html permanent;
This will work with profiles, posts, threads and forums
Pages: 1 2 3