Redirecting MyBB URL's

m1ne

Well-known member
Hello.

I've not converted my MyBB forum yet, but I know this will be a problem, so I am posting now.
Is there any way to redirect old MyBB url's to XF links? Using htaccess perhaps?
MyBB URL's look like this,

/thread-30028.html
/forum-121.html
/user-2.html

I've got a lot of indexed url's so I hope there's a way to do this.

Thank you.
 
I was looking for someone with a similar experience but I can't find it.
My case: I'm changing from oldserver & olddomain with Mybb to newserver&newdomain with Xenforo.
I already imported threads, members... in the newserver and newdomain using http://xenforo.com/help/importing/

Now my question is, how can I redirect mybb properly? I read this: http://xenforo.com/help/import-redirection/

Should I import these scripts at newserver? http://xenforo.com/community/threads/redirection-scripts-for-vbulletin-3-x.5030/
Or they should be placed at oldserver?
Should I change htaccess at oldserver or at newserver?

Thanks for your help!

There are several variables. Please provide an example old and new thread URL. That will allow me to provide you with specific instructions.
 
Thanks Jake, probably there's not an easy solution.
I was using the plugin "Google SEO" at MyBB. It turned the threads from:
http://www.smartwtachmania.com/thread-threadID.html
to
http://www.smartwatchmania.com/Tema-Pebble-water-resistant (this is the URL indexed at Google).
URL at xenforo:
http://www.swmania.com/threads/pebble-water-resistant.2170/

The same with forums and members.
The only solution I found is to manually add the most important threads at htaccess. For example:
Code:
Redirect 301 /Tema-Apps-para-Pebble-recomendadas http://www.swmania.com/threads/238/

I already did it to all forums (they were only 20):
Code:
Redirect 301 /Foro-General http://www.swmania.com/forums/general.13/

I added this code to redirect Users:
Code:
RewriteRule ^Usuario-([^./]+)$ http://www.swmania.com/members/ [R=301,L]

And tried the same for threads:
Code:
RewriteRule ^Tema-([^./]+)$ http://www.swmania.com/search/ [R=301,L]
It worked, but it also works for the manually added and most important threads. So I turned it off.
This last code it's at bottom, so should be processed after the other redirects... don't know what's not working there.
Any help with this?

My tip for anyone at the same situation: turn OFF "Google SEO" plugin at least one month before changing from Mybb to Xenforo, so the non-SEO urls will be indexed in Google and they are easier to redirect.
 
Thanks Jake, probably there's not an easy solution.
I was using the plugin "Google SEO" at MyBB. It turned the threads from:
http://www.smartwtachmania.com/thread-threadID.html
to
http://www.smartwatchmania.com/Tema-Pebble-water-resistant (this is the URL indexed at Google).
URL at xenforo:
http://www.swmania.com/threads/pebble-water-resistant.2170/

The same with forums and members.
The only solution I found is to manually add the most important threads at htaccess. For example:
Code:
Redirect 301 /Tema-Apps-para-Pebble-recomendadas http://www.swmania.com/threads/238/

I already did it to all forums (they were only 20):
Code:
Redirect 301 /Foro-General http://www.swmania.com/forums/general.13/

I added this code to redirect Users:
Code:
RewriteRule ^Usuario-([^./]+)$ http://www.swmania.com/members/ [R=301,L]

And tried the same for threads:
Code:
RewriteRule ^Tema-([^./]+)$ http://www.swmania.com/search/ [R=301,L]
It worked, but it also works for the manually added and most important threads. So I turned it off.
This last code it's at bottom, so should be processed after the other redirects... don't know what's not working there.
Any help with this?

My tip for anyone at the same situation: turn OFF "Google SEO" plugin at least one month before changing from Mybb to Xenforo, so the non-SEO urls will be indexed in Google and they are easier to redirect.

I have dealt with that before. MyBB maintains a slug record for each thread. It is possible to redirect using rewrites and a custom script.

Copy the mybb_google_seo table from MyBB's database to XF's database. Then upload the attached script to your XF root (where XF is installed). Be sure to edit that script to specify your forum URL.

Then you need rewrites to pass the slug to the script. Does smartwatchmania.com have a different web root than swmania.com? That would be ideal to avoid conflicts. Otherwise we will need to be careful in constructing the patterns.
 

Attachments

Does smartwatchmania.com have a different web root than swmania.com? That would be ideal to avoid conflicts. Otherwise we will need to be careful in constructing the patterns.

Actually... we can just check the host portion. So add these rules to the top of the .htaccess file in the web root for smartwatchmania.com:

Code:
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?smartwatchmania\.com$
RewriteRule ^([^/]+)$ http://www.swmania.com/mybbthreadredir.php?slug=$1 [R=301,L]
 
Thanks @Jake Bunce! I though that was a lost battle.
I did all the steps you mentioned, but it doesn't work.
  1. mybb_google_seo imported at Xenforo db
  2. script at XF root (swmania.com)
  3. URL changed
  4. .htaccess changed at smartwatchmania.com
I using any old URL I get a blank page with this URL:
http://www.smartwatchmania.com/Tema-VIDEO-Omate-Truesmart-en-acción
http://www.swmania.com/mybbthreadredir.php?slug=Tema-VIDEO-Omate-Truesmart-en-acción

At the script mybbthreadredir.php I just changed the Location:
Code:
$id = $db->fetchOne("
    SELECT id
    FROM mybb_google_seo
    WHERE url = ?
    AND active = 1
    AND idtype = 4
", $_REQUEST['slug']);

if ($id)
{
    header ('HTTP/1.1 301 Moved Permanently');
    header ('Location: http://www.swmania.com/threads/' . $id);
}
Actually, it's the same web root :(

Thanks in advance for your help!
 

There are two components to this redirect, and those URLs indicate that neither one is working. Let's start with the second one.

It appears that threads may have "Tema-" in the URL as some kind of prefix. You will see that this works:

http://www.swmania.com/mybbthreadredir.php?slug=Pebble-water-resistant

...but not this:

http://www.swmania.com/mybbthreadredir.php?slug=Tema-Pebble-water-resistant

So we know that works when we fix the slug. So we just need to fix the rewrite rule. Try this:

Code:
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?smartwatchmania\.com$
RewriteRule ^Tema-([^/]+)$ http://www.swmania.com/mybbthreadredir.php?slug=$1 [R=301,L]
 
The htaccess at the old web (smartwatchmania.com) has just that:
Code:
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?smartwatchmania\.com$
RewriteRule ^Tema-([^/]+)$ http://www.swmania.com/mybbthreadredir.php?slug=$1 [R=301,L]
At the new swmania.com web:
Code:
#    Mod_security can interfere with uploading of content such as attachments. If you
#    cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
#    SecFilterEngine Off
#    SecFilterScanPOST Off
#</IfModule>

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.swmania\.com$ [NC]
    RewriteRule ^(.*)$ http://www.swmania.com/$1 [R=301,L]

RewriteRule ^thread-([0-9]+)\.html http://www.swmania.com/threads/$1 [NC,L]
RewriteRule ^thread-([0-9]+)-lastpost\.html http://www.swmania.com/threads/$1 [NC,L]
RewriteRule ^user-([0-9]+)\.html http://www.swmania.com/members/$1 [NC,L]
RewriteRule ^forum-([0-9]+)\.html http://www.swmania.com/forums/$1 [NC,L]
RewriteRule ^Usuario-([^./]+)$ http://www.swmania.com/members/ [R=301,L]
RewriteRule ^(usercp2|newthread|private|portal|usercp|polls|stats|misc|search)\.php$ /search/? [R=301,L]
RewriteRule ^(member|memberlist|showteam)\.php$ /members/ [R=301,L]
# RewriteRule ^Tema-([^./]+)$ http://www.swmania.com/search/ [R=301,L]

    #    If you are having problems with the rewrite rules, remove the "#" from the
    #    line that begins "RewriteBase" below. You will also have to change the path
    #    of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    #    This line may be needed to enable WebDAV editing with PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>

PS: well, in fact I have several manual redirections in this new htaccess like

Code:
Redirect 301 /Tema-Android-PebbleDialer-Controles-de-llamada http://www.swmania.com/threads/android-pebbledialer-controles-de-llamada.308/

Redirect 301 /online.php http://www.swmania.com/online/

Redirect 301 /Foro-General http://www.swmania.com/forums/general.13/
 
Last edited:
Put my rules at the top of XF's .htaccess. Both domains are apparently pointing to your XF web site.
Hi Jake, I tried it but it's still not working.
I also tried this code without success:
Code:
Redirect 301 /mybbthreadredir.php?slug=Tema- http://www.swmania.com/mybbthreadredir.php?slug=
 
Sorry it took so long. I have been very busy.

I just fixed this.

The two domains are actually on separate sites such that I had to add my rules to the .htaccess file on the old site. Now it works.
 
I have dealt with that before. MyBB maintains a slug record for each thread. It is possible to redirect using rewrites and a custom script.

Copy the mybb_google_seo table from MyBB's database to XF's database. Then upload the attached script to your XF root (where XF is installed). Be sure to edit that script to specify your forum URL.

Then you need rewrites to pass the slug to the script. Does smartwatchmania.com have a different web root than swmania.com? That would be ideal to avoid conflicts. Otherwise we will need to be careful in constructing the patterns.

Hi, I have moved MyBB to mysite.com/archives, and installed XF at mysite.com. I have copied the mybb google seo database as you described above. What should I write in "Location" in the phpfile you posted?

And can someone help me with the text i have to put in .htaccess? Thanks a lot :)
 
Last edited:
What should I write in "Location" in the phpfile you posted?

Your XF URL:

Rich (BB code):
if ($id)
{
	header ('HTTP/1.1 301 Moved Permanently');
	header ('Location: http://yoursite.com/threads/' . $id);
}

And can someone help me with the text i have to put in .htaccess? Thanks a lot :)

Please provide an example old and new thread URL (MyBB and XF). Then I can be certain about your redirects and provide exact instructions.
 
Last edited:

Put these rules at the top of the .htaccess file in the web root for http://mysite.com/

Code:
RewriteEngine On
RewriteRule ^Thread-([^/]+)$ /mybbthreadredir.php?slug=$1 [R=301,L]

And make sure the mybbthreadredir.php file (previously attached) is uploaded to the web root for http://mysite.com/, and that the mybb_google_seo table has been copied to your XF database (as previously mentioned).
 
Put these rules at the tforums the .htaccess file in the web root for http://mysite.com/

Code:
RewriteEngine On
RewriteRule ^Thread-([^/]+)$ /mybbthreadredir.php?slug=$1 [R=301,L]

And make sure the mybbthreadredir.php file (previously attached) is uploaded to the web root for http://mysite.com/, and that the mybb_google_seo table has been copied to your XF database (as previously mentioned).

Does this work for more than threads? For example links to users, posts and forums?
EDIT : NVM

Thanks a lot for the great support :)
 
Last edited:
Does this work for more than threads? For example links to users, posts and forums?
EDIT : NVM

Thanks a lot for the great support :)

Upload this slightly modified script for forums, then add an appropriate RewriteRule to your .htaccess to pass those URLs to the forum script. The difference is in the "idtype" in the query and the URL in the "Location".
 

Attachments

Top Bottom