- Compatible XF 2.x versions
-
- 2.0
- 2.1
- 2.2
- Visible branding
- No

Option 1 - Using .htaccess
There are a few things for .htaccess to work correctly:
- SMF 2.0 was using normal URLs, like "https://www.domain.com/smf/index.php?board=5.0"
- During the import to Xenforo, you choose to retain ID's
After RewriteEngine On add:
Code:
RewriteCond %{QUERY_STRING} (^|\?|&)board=([0-9]+)\.[0-9]+($|&)
RewriteRule ^index\.php$ /forum/forums/%2/? [R=301,L]
RewriteCond %{QUERY_STRING} (^|\?|&)topic=([0-9]+)\.[0-9]+($|&)
RewriteRule ^index\.php$ /forum/threads/%2/? [R=301,L]
RewriteCond %{QUERY_STRING} (^|\?)topic=([0-9]+).msg([0-9]+)($|&)
RewriteRule ^index\.php$ /forum/threads/%2/#post-%3? [NE,R=301,L]
RewriteCond %{QUERY_STRING} (^|\?)PHPSESSID=(.*);topic=([0-9]+)\.[0-9]+($|&)
RewriteRule ^index\.php$ /forum/threads/%3/? [NE,R=301,L]
Option 2 - Using Nginx Rewrites
The follow rules will redirect from yourdomain.com/forum/ to yourdomain.com/
Code:
# rewrite rules to redirect SMF URLs
# Message redirects
# matching /forum/index.php/topic,101126.msg3826887.html
rewrite ^/forum/index\.php/topic,[0-9]+\.msg([0-9]+)/?(?:wap2|topicseen)?\.html /posts/$1/ permanent;
# matching /forum/index.php?topic=101126.msg3826887
if ($arg_topic ~ [0-9]+\.msg([0-9]+)$) {
set $postid $1;
rewrite ^/forum/index\.php /posts/$postid/? permanent;
}
# matching /forum/index.php?msg=3826887
if ($arg_msg ~ "^([0-9]+)(?:;wap2|$)") {
set $postid $1;
rewrite ^/forum/index\.php /forum/posts/$postid/? permanent;
}
# Thread / Topic redirects
# matching /forum/index.php/topic,101523.25.html
rewrite ^/forum/index\.php/topic,([0-9]+)\.[0-9]+/?(?:wap2|wap|nowap|all|prev|prev_next|prev_next,prev|prev_next,next|topicseen|page2)?\.html /threads/$1/ permanent;
# matching /forum/index.php%3Ftopic%3D96737.0
# http://stackoverflow.com/questions/20470191/external-links-url-encoding-leads-to-3f-and-3d-on-nginx-server
rewrite ^/forum/index\.php\?topic=([0-9]+)\.[0-9]+ /threads/$1/ permanent;
# matching /forum/index.php?topic=65856.0
if ($arg_topic ~ "^([0-9]+)\.[0-9]+(?:;wap2|$)") {
set $threadid $1;
rewrite ^/forum/index\.php /threads/$threadid/? permanent;
}
# Boards redirects
# matching /forum/index.php/board,13.0.html
rewrite ^/forum/index\.php/board,([0-9]+)\.[0-9]+\.html /forums/$1/ permanent;
# matching /forum/index.php%3Fboard%3D3.0
rewrite ^/forum/index\.php\?board=([0-9]+)\.[0-9]+ /forums/$1/ permanent;
# matching /forum/index.php?board=13
if ($arg_board ~ "^([0-9]+)(?:;wap2|$)") {
set $boardid $1;
rewrite ^/forum/index\.php$ /forums/$boardid/? permanent;
}
# matching /memberlist.php?mode=viewprofile&u=2745
rewrite ^/memberlist\.php$ /members/$arg_u/? permanent;
# Redirect old forum homepage
rewrite ^/forum/index.php$ /forums/? permanent;
rewrite ^/forum/ /forums/? permanent;
# Redirect avatar folder (Friendly URLs bug)
rewrite ^/account/avatar /index.php?account/avatar;
# Redirect RSS feed location
rewrite ^/forums/-/index.rss /index.php?forums/-/index.rss;
Option 3 - PHP Script
You can also use a script to redirect SMF to XF. Works with Apache and Nginx.
This script also handles thread page redirects, which the .htaccess / nginx option does not have! This is because it needs a bit of calculation.
There are a few things for the script to work correctly:
- SMF 2.0 was using normal URLs, like "https://www.domain.com/smf/index.php?board=5.0"
- During the import to Xenforo, you choose to retain ID's
- Both forums are installed in separate directories (or domains)
Download the script and modify to your needs.
Put it in the original location of your old SMF forum, overwriting the original index.php file.
You will need to change these variables in the script:
Code:
// *** Variables ***
$redir_url = 'https://www.yourdomain.com'; // URL of your new forum, without trailing slash
$friendly_url = '1'; // 0 = Don't use XF friendly URL's / 1 = use XF friendly URL's
$forums = 'forums'; // Default path to index (only change this if you are using route filters)
$threads = 'threads'; // Default path to topic (only change this if you are using route filters)
$posts = 'posts'; // Default path to posts (only change this if you are using route filters)
$members = 'members'; // Default path to members (only change this if you are using route filters)
$threads_count = 20; // Make sure the number of messages per page is the same for SMF and XenForo.
$mode = 0; // 0 = testing / 1 = temp redirect / 2 = perm redirect
Note 1: If you installed Xenforo in a subdirectory, you can use something like $redir_url = 'https://www.yourdomain.com/subdir';
Note 2: Make sure you use the same value for the number of messages per page for both forums.
So, if SMF was setup for 10 messages per page, you should do the same for Xenforo (Setup > Options > Threads > Discussions per page) and modify $threads_count to 10. This way you can also redirect thread pages correctly!
Examples of the redirections this script handles:
- Redirect boards:
https://www.yourdomain.com/smf/index.php?board=5.0 >>> /xenforo/forums/5/
- Redirect a specific message:
https://www.yourdomain.com/smf/index.php?msg=123 >>> /xenforo/posts/123/
- Redirect a specific message in a topic:
https://www.yourdomain.com/smf/index.php?topic=10.msg123 >>> /xenforo/posts/123
- Redirect to a specific page:
https://www.yourdomain.com/smf/index.php?topic=10.110 >>> /xenforo/threads/10/page-12
- Redirect profiles:
https://www.yourdomain.com/smf/index.php?action=profile;u=123 >>> /xenforo/members/123/
- If nothing matches, it will redirect to your default forum URL.