MyBB-Google-SEO icon indicating copy to clipboard operation
MyBB-Google-SEO copied to clipboard

Redirection of links due to forum migration?

Open ghost opened this issue 7 years ago • 5 comments

I'm currently on Mybb, but will be migrating to Xenforo (Client's decision). Problem is, so far we've used for months links like this: "https://site.com/Thread-This-is-the-title"

Without the ID in them. (Imagine that for this example link the id is 1234)/ Xenforo has links like these: "https://site.com/threads/1234/"

If I migrate right now, anyone with one of the old mybb links would NOT be redirected to the new URL, because there is no rule I can make in .htaccess that adds the ID, as the original link doesn't have it.

I already changed the current config so that all mybb links have the ID in them, but that doesn't change the fact users will use the old links if they find them on google or on other forums.

My question is, is there any way to redirect correctly without the id in the link? Any script, or idea? I'd very much appreciate the help. Thanks in advance.

ghost avatar Feb 10 '18 15:02 ghost

Google SEO redirects Thread-Title links back to showthread.php?tid=123 links, if you revert code changes or set scheme URL to empty.

If you keep the database and MyBB code alive (move to a subdir) and rewrite Google SEO URLs to that subdir, it will continue doing those redirects for you. Then your new forum software can pick up the showthread.php?tid=123 links and redirect those to what-ever it is in the new forum system.

Basically old rewriterule:

RewriteRule ^Thread\-([^./]+)$ showthread.php?google_seo_thread=$1 [L,QSA,NC]

New rewriterule:

RewriteRule ^Thread\-([^./]+)$ old_mybb/showthread.php?google_seo_thread=$1 [L,QSA,NC]

That'd be the approach that doesn't involve any additional coding. The script is already there. Redirecting back to original URLs, was part of GoogleSEO's features from the start. Only catch is that you have to keep GoogleSEO (and thus MyBB) installed somewhere.

Of course, you could condense that into more concise code by taking only the relevant portions from redirect.php and url.php, and only the google_seo table, with no need to keep the full mybb install around. Then rewrite everything to a standalone google_seo_redirect.php which knows how to query the google_seo table same way Google SEO itself does. But I don't have such a script at this time, sorry.

If anyone wants to contribute such a thing, I'd be happy to add it into the package.

frostschutz avatar Feb 10 '18 16:02 frostschutz

That'd be the approach that doesn't involve any additional coding. The script is already there. Redirecting back to original URLs, was part of GoogleSEO's features from the start. Only catch is that you have to keep GoogleSEO (and thus MyBB) installed somewhere.

Thank you for answering so quickly and with such detail! I don't mind keeping Mybb around in a secondary directory, no problem.

But, If I change the rewrite rule like you mention, wouldn't that just redirect all old mybb links to the mybb thread instead of the new xenforo thread? Am I not missing an extra rule?

ghost avatar Feb 10 '18 16:02 ghost

It will redirect to yoursite/showthread.php?tid=123 (not the subdir, provided you don't set bburl to the subdir, which you shouldn't do). So even though MyBB is in a subdir, Google SEO will still believe the non-subdir is the correct location, according to your bburl setting.

of course you need something to pick it up from there, I can't help you with that. your new forum needs to know at minimum how to redirect the original mybb URLs.

frostschutz avatar Feb 10 '18 16:02 frostschutz

your new forum needs to know at minimum how to redirect the original mybb URLs.

Perhaps what I'm going to say is wrong, but then would adding a rule like this after the one you mentioned do the trick? Something like:

RewriteRule ^showthread.php?tid=([0-9+])$ threads/$1 [L,QSA,NC]

Considering xenforo links are of the form https://site.com/threads/1234/

ghost avatar Feb 10 '18 17:02 ghost

You'd have to match %{QUERY_STRING} instead.

RewriteCond %{QUERY_STRING} tid=([0-9]+)
RewriteRule showthread.php threads/%1

or something like it

frostschutz avatar Feb 10 '18 17:02 frostschutz