Migrating from vBulletin to Discourse and want to redirect old vBulletin URLs to new Discourse URLs? Read on!
If the base URL of your old forum and new forum is same, you should follow this howto instead:
In this howto we’ll assume:
-
vBulletin base URL:
www.example.com/forum
-
Discourse base URL:
forum.example.com
-
Nginx server for
www.example.com
Let’s begin!
Generate Nginx map file
To set up categories and topics redirect we’ll use Nginx map module. The CSV file will be generated (script/import_scripts/vb_map.csv
) while performing import via create_permalinks
method. We’ll paste the content of CSV file into map file on server.
File sample contents:
...
/forum/forumdisplay.php?6 http://forum.example.com/c/games;
/forum/forumdisplay.php?7 http://forum.example.com/c/movies;
/forum/forumdisplay.php?13 http://forum.example.com/c/admin;
/forum/showthread.php?1 http://forum.example.com/t/x/22;
/forum/showthread.php?2 http://forum.example.com/t/x/23;
/forum/showthread.php?3 http://forum.example.com/t/x/24;
/forum/showthread.php?4 http://forum.example.com/t/x/25;
...
Copy the entire content of generated CSV file to etc/nginx/vb_forum.map
on www.example.com
’s server.
Edit nginx.conf
Edit the /etc/nginx/nginx.conf
file to add this code in http
block:
map_hash_bucket_size 128;
map_hash_max_size 80000;
map $request_uri $new {
include /etc/nginx/vb_forum.map;
}
server {
listen 80;
server_name www.example.com;
location ~ ^/forum\/showthread.php {
if ($args ~* ^(\d+)-(.+)$) {
set $tid $1;
set $args '';
rewrite ^ /forum/showthread.php?$tid permanent;
}
if ($args ~* ^t=(\d+)$) {
set $tid $1;
set $args '';
rewrite ^ /forum/showthread.php?$tid permanent;
}
return 301 http://forum.example.com;
}
location ~ ^/forum\/forumdisplay.php {
if ($args ~* ^(\d+)-(.+)$) {
set $tid $1;
set $args '';
rewrite ^ /forum/forumdisplay.php?$tid permanent;
}
if ($args ~* ^f=(\d+)$) {
set $tid $1;
set $args '';
rewrite ^ /forum/forumdisplay.php?$tid permanent;
}
return 301 http://forum.example.com;
}
if ($new) {
rewrite ^ $new permanent;
}
location /forum {
return 301 http://forum.example.com;
}
}
map_hash_max_size
needs to be adjusted based on number of URLs present in map file.
Verify nginx.conf
Verify your Nginx config file:
nginx -c /etc/nginx/nginx.conf -t
Reload your Nginx config to include your changes:
sudo systemctl reload nginx
Try reaching www.example.com/forum
, you should now be getting redirected to forum.example.com
.
Following types of URLs will be handled by above Nginx config:
-
www.example.com/forum
→forum.example.com
-
www.example.com/forum/forumdisplay.php?6
→forum.example.com/c/games
-
www.example.com/forum/forumdisplay.php?6-Games
→forum.example.com/c/games
-
www.example.com/forum/forumdisplay.php?f=6
→forum.example.com/c/games
-
www.example.com/forum/showthread.php?2
→forum.example.com/t/topic-slug/23
-
www.example.com/forum/showthread.php?2-topic-slug
→forum.example.com/t/topic-slug/23
-
www.example.com/forum/showthread.php?t=2
→forum.example.com/t/topic-slug/23
Last edited by @JammyDodger 2024-05-27T14:59:36Z
Check document
Perform check on document: