XF 1.0 How to redirect vb #post3324 to xf #postid-1234

Marcus

Well-known member
How can I redirect a vb thread showthread.php?t=73139#post3324 to threads/234/#postid-1234 ? It does not work currently. Thanks.
 
Did you import from vBulletin? If so then you can use these redirect scripts:

http://xenforo.com/community/threads/redirection-scripts-for-vbulletin-3-x.5030/

If you only want to redirect one specific URL then you can use this code in a .htaccess file (only works on Apache servers):

Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/showthread\.php$
RewriteCond %{QUERY_STRING} ^t=73139$
RewriteRule ^ http://www.yoursite.com/threads/234/? [R=301,L]

That will perform the desired redirect for that specific thread, minus the anchors which can't be manipulated by the server.
 
Hi Jake, thanks! I have imported from vb and the redirection script works for threads alone. But once I have a redirection to a special post within a thread, the redirection script
- does not direct me to the right page
- and therefore does not direct me to the right post.

This is a sample URL:
showthread.php?t=123&page=3#post546878
-> anchor redirection is possible with jquery for the anchor

Sometimes vb4 writes the same topic like this:
showthread.php?t=123&page=3&postid=546878#post546878
-> anchor redirection is possible with jquery for the anchor
-> anchor redirection is also possible also with &postid
 
You can't redirect (on the server side) based on an anchor, as it's not sent to the server. You'd have to do some custom JS to do that.
 
Hi Mike, this is exactly what I said. I have some questions regarding the redirector:

- page=x are not redirected, is that a bug?
- if there is a &postid=x in the url, should this be redirected to the right page with the anchor #post-y?

By the way, I manipulate my page depending on the anchors with jquery actually.
 
It doesn't try to keep the specific page as it stands. And I don't think "postid" is normally in URLs like that - is that a vB4 thing? (We have redirects for "p".)
 
So onces I migrate to xenforo from vb all my thread page urls are not taken care of?
And the post-anchors are also not taken care of, right?
My users very often link within threads to other posts within the same thread, this information would all be lost?

This is not only huge for my members but also for SEO as my site structure is also built on the various inline-linking which all now would permanently redirect to a different content.
 
And I don't think "postid" is normally in URLs like that - is that a vB4 thing? (We have redirects for "p".)

"postid" was a vB2 thing. vB3 and vB4 use "p" by default but they also recognize "postid" (probably to maintain compatibility with old links). It's the same for "threadid" and "t".

And the post-anchors are also not taken care of, right?

As I said, the server can't manipulate anchors. The server can't see the anchor because it is not sent as part of the request. Here is a demonstration of this that I found a while ago:

http://delorie.com:81/type-whatever-on-your-mind-here#and-here-too
 
I don't understand why not even the right page is served when the page is given in the url, or when xf looks up a post and delivers a thread, then the thread should be served with the right page. Is there even a old_id | post table stored after the import? If yes, you could use this. The current implementation of the 301 redirector is rather basic. It should not be hard for any xf addon dev to fetch the anchor with jquery and then redirect to the right page.
 
The page numbers don't necessarily match up. The number of posts per page might be different. So if the URL provides a threadid and page number then XenForo can only redirect to the threadid. I just tested and confirmed this:

original: showthread.php?t=9710&page=2
redirect: index.php?threads/thread-title.9013/

I suppose the redirect script could check the number of posts per page and then specify the page only if that number is the same. That would require the importer to record the number of posts per page in the import log.

As for the postids... if a postid is given in the URL then it is redirected to the correct page with an anchor. I just tested this myself. For example:

original: showpost.php?p=118757
redirect: index.php?threads/thread-title.9013/page-2#post-116535

original: showthread.php?p=118757#post118757
redirect: index.php?threads/thread-title.9013/page-2#post-116535

When the URL contains a postid you can make a correct redirect like this. But the postid must be part of the query string. If the postid is only specified as an anchor then the server won't see it. As Mike suggested, this may be possible with javascript.
 
Thanks very much for your very helpful post. I have the same posts/page setup in both my forums, how else would the pages match :D I have missed the outstanding ?p redirection, this is excellent integration from xenforo!

Once there is an integration for pages, too I am migrating to xf. But without that, I'd very much have my IDs stay the same after the migration so that none of these anchor issues are even there.
 
I see Kiers script http://xenforo.com/community/threads/post-content-find-replace.6548/ can help me rewrite all old urls into new xf ones with a bit tweaking. That could be a big help.

Maybe. Updating forum links after an import requires mapping the old ids to the new ones, and that find / replace tool doesn't do that. It is useful for updating BB codes and updating links to point to a different directory if you move your forum, but it doesn't do any id mapping like the redirect scripts do.

Here are some specific examples of how that addon can be used:

http://xenforo.com/community/threads/phpbb-import.17942/#post-233165
http://xenforo.com/community/threads/removing-mybb-tags-after-importing-database.19558/#post-251195
 
From a short view over Kiers script, in PostReplace.php you can easy configure public function actionReplace() to query through each found old_id and replace it with the current new_id. Pretty easy but powerful stuff.
 
This is a quick and easy help to just use Kiers importer to greatly improve your internal links:

Replace this
showthread.php?t={1}#post{2}
to this
showthread.php?t={1}&p={2}#post{2}
 
There is a problem with links from vb without a threadid.
I have only showthread.php?p=12345

Now i have no idea how to replace (or rewrite) it.
Can xenforo call a thread only with the postid, please?
 
Top Bottom