Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirection of links due to forum migration? #61

Open
ghost opened this issue Feb 10, 2018 · 5 comments
Open

Redirection of links due to forum migration? #61

ghost opened this issue Feb 10, 2018 · 5 comments

Comments

@ghost
Copy link

ghost commented Feb 10, 2018

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.

@frostschutz
Copy link
Owner

frostschutz commented Feb 10, 2018

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.

@ghost
Copy link
Author

ghost commented Feb 10, 2018

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?

@frostschutz
Copy link
Owner

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.

@ghost
Copy link
Author

ghost commented Feb 10, 2018

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/

@frostschutz
Copy link
Owner

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

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

or something like it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant