XF 1.3 Redirects after custom conversion

Floyd R Turbo

Well-known member
I'm working on a potentially difficult project - conversion of a DNN forum to Xenforo. The forum is about 7 years old and has roughly 18,000 threads and 170,000 posts.

The link structure of DNN is, well, horrid. Something like this

www.domain.com/Forums/tabid/78/aft/34624/Default.aspx

I have a company working on a dry-run conversion, which should be done this week. If that shows promise, then I will need to work on many other things, but redirects will be one of high importance.

I guess I don't know where to start, so I'm looking for a point in the right direction.

Something like a 18,000 row, 2 column table that just has "original URL" and "new URL" that would be referenced when the link was requested.

It wouldn't take me long to figure out the logic behind the messy DNN URL structure, but then mapping these over to xF might not be quite so easy.

Any help would be appreciated.
 
The normal approach is to redirect based on IDs (either keeping them the same or storing them in a mapping table). Without that though, you would need to map each URL manually. But regardless, there would need to be custom development involved.
 
I'm hoping that I will be able to create a mapping table, or have IDs the same as you mention. Hence the reason for a dry run - ASAIK I'm the first one to convert such a large DNN forum to XF (or anything else for that matter)

What level of complexity is involved in the redirect script? Is this something I could figure out myself by reverse-engineering another one? I may not be up to current coding levels knowledge wise, but back in elementary and high school, I was quite the whiz at BASICA FORTRAN and PASCAL. :LOL: My programming ended in college when I tested out of the prerequisite course and didn't need any more for me EE degree.
 
Jumping back into this, I'm hoping that I can get some more specific direction as I am not very knowledgeable here. Not a pressing issue, but I have to take care of this. Perhaps @Jake Bunce can help me out.

The current links look like this when I am actually viewing the particular thread:

www.domain.org/Forums/tabid/78/aft/34578/Default.aspx

But if I am on the sub-forum and right-click-copy the link to the thread, it's this when I paste it:

www.domain.org/Forums/tabid/78/aff/5/aft/34578/afv/topic/afnp/103898/Default.aspx

...which internally on DNN resolves to the first link. I have no idea why the second is so much more complex, except that the number 5 corresponds to the forum ID. The number 78 is in every forum/thread related link. No idea what the 103898 number means, but it does not correlate to the post number, at all (and it is not specific to a thread, many thread links on the forum page have this number in it - very odd)

There are other formations of the links but the pattern is that af=activeforums (DotNetNuke/DNN) and aft=thread aff=forum afv=?? afnp=??(new post ID??) afpg=page

The number that matters in this example is 34578 which is the thread ID in the DNN database = aft/34578.

I'm having the conversion company put together a mapping table for thread IDs but in this example, I know it maps to the XF thread ID 21782 as such:

www.domain.org/threads/threadtitle.21782/

So this seems simple to me, I need to structure the redirects such that it just pulls out the number after /aft/oldthreadID# and then uses the mapping table to spit out www.domain.org/threads/.newthreadID#, which will correctly resolve to the XF thread. The old DNN forum does not have permalinks for posts so this really covers most of what I want to convert as far as thread links go.

Forum links are all pretty simple:

www.domain.org/Forums/tabid/78/aff/4/Default.aspx where aff=forum ID (4, in this case), and these are not very many so I would be able to map this manually very easily - and this is rarely linked in such a way (except maybe by google/etc)

Other links I need to work on something for are related to photos and videos but...one step at a time.

So, I don't really know exactly what needs to be done once I have the mapping table. As @Mike mentioned I might have to use some kind of modded solution, but I need a point in the right direction.

Thanks ahead of time.
 
Assuming:

old - www.domain.org/Forums/tabid/78/aft/34578/Default.aspx
new - www.domain.org/threads/threadtitle.21782/

Add these rules to the top of the .htaccess file in your /Forums directory:

Code:
RewriteEngine On

RewriteRule ^tabid/[0-9]+/aft/([0-9]+)/Default\.aspx$ /showthread.php?t=$1 [R=301,L]

Then upload these scripts to your web root:

https://xenforo.com/community/resources/redirection-scripts-for-vbulletin-3-x.264/

By default these scripts will use the xf_import_log table for the id mapping, so you should put your map in that table using the same schema.
 
Thanks!

I think that will cover the majority of the instances. The one that could screw things up (and I don't know how prevalent this pattern would be) is the other URL formation

www.domain.org/Forums/tabid/78/aff/5/aft/34578/afv/topic/afnp/103898/Default.aspx

but that would likely be covered by using another forum of the same rule, such as this, correct?

Code:
RewriteRule ^tabid/[0-9]+/aff/[0-9+]/aft/([0-9]+)/afv/topic/afnp/[0-9]+/Default\.aspx$ /showthread.php?t=$1 [R=301,L]

Is there a way to write a rewrite rule so that one the condition that I care about is reached (in this case, everything in the ([0-9]+) section) I don't care what is between that string and default.aspx?

Edit: what might be easier would be to use Post Find/replace to just just those odd instances. Then I would only be at the mercy of links from external sites using odd structure and would just default those to the main page. I think for SEO just the actual thread URL should cover it...
 
By default these scripts will use the xf_import_log table for the id mapping, so you should put your map in that table using the same schema.
@Jake Bunce so I have the mapping table created - just a 2 column excel spreadsheet with [old thread id] in column 2 and [new thread id] in column 2. But I don't have a table in the DB called xf_import_log. I have one on another forum when I converted from VB4.x to XF a year ago, but it's empty. So can I just import my excel spreadsheet (CSV) and if so, what do the column headers need to be named?
 
Amended...

Assuming:

old - www.domain.org/Forums/tabid/78/aft/34578/Default.aspx
new - www.domain.org/threads/threadtitle.21782/

old - www.domain.org/Forums/tabid/78/aff/5/aft/34578/afv/topic/afnp/103898/Default.aspx
new - www.domain.org/threads/threadtitle.21782/

Add these rules to the top of the .htaccess file in your /Forums directory:

Code:
RewriteEngine On

RewriteRule ^tabid/[0-9]+/aft/([0-9]+)/Default\.aspx$ /showthread.php?t=$1 [R=301,L]
RewriteRule ^tabid/[0-9]+/aff/[0-9]+/aft/([0-9]+)/afv/topic/afnp/[0-9]+/Default\.aspx$ /showthread.php?t=$1 [R=301,L]

Then upload these scripts to your web root:

https://xenforo.com/community/resources/redirection-scripts-for-vbulletin-3-x.264/

By default these scripts will use the xf_import_log table for the id mapping, so you should put your map in that table using the same schema.

@Jake Bunce so I have the mapping table created - just a 2 column excel spreadsheet with [old thread id] in column 2 and [new thread id] in column 2. But I don't have a table in the DB called xf_import_log. I have one on another forum when I converted from VB4.x to XF a year ago, but it's empty. So can I just import my excel spreadsheet (CSV) and if so, what do the column headers need to be named?

Your XF database will have a xf_import_log table to look at. You need to populate that table with your old and new thread_ids.
 
I do not have an xf_import_log table, at all, in the current conversion. It was a custom conversion from DotNetNuke. Even when I did my vb4.x to xf conversion a year ago (on another site) I have the table, but no columns (totally empty - no names even). So I have no frame of reference to start from :(

So what should the column headers be named? Does it matter? I assume it would have to or else the call would fail...right?
 
I do not have an xf_import_log table, at all, in the current conversion. It was a custom conversion from DotNetNuke. Even when I did my vb4.x to xf conversion a year ago (on another site) I have the table, but no columns (totally empty - no names even). So I have no frame of reference to start from :(

So what should the column headers be named? Does it matter? I assume it would have to or else the call would fail...right?

Even with an empty table you can still view the structure in phpmyadmin. That will show you the columns in the table.

Your populated import log might be named archived_import_log if you want to look for a populated import log as a point of reference.
 
Apparently I needed :coffee: I see the columns are content_type, old_id and new_id so that is pretty straight forward. I assume content_type corresponds with the content_type filed in xf_content_type

I'll give this a go today...
 
Oh I think I just caught something...

My XF installation is in the web root (public_html folder) not in /forums or /community, etc.

The /Forums section of the old link is that site's URL linkology...I don't have a /Forums in my test site

Does this make a difference? Do I need to create this and put a .htaccess w/redirects in that dir, or do the rewrite rules need to be changed?


NVM

I made a /Forums sub dir, put the rewrite rules in there, uploaded scripts and mapping table, ran a few Post Find Replace strings and BAM perfection. THANK YOU!!!
 
Last edited:
Back
Top Bottom