Stai migrando da vBulletin a Discourse e vuoi reindirizzare i vecchi URL di vBulletin ai nuovi URL di Discourse? Continua a leggere!
Se l’URL di base del tuo vecchio forum e del nuovo forum è lo stesso, dovresti seguire questa guida invece:
Redirect old forum URLs to new Discourse URLs using permalinks
In questa guida assumeremo:
-
URL di base di vBulletin:
www.example.com/forum -
URL di base di Discourse:
forum.example.com -
Server Nginx per
www.example.com
Cominciamo!
Genera il file di mappatura Nginx
Per configurare il reindirizzamento di categorie e argomenti, utilizzeremo il modulo map di Nginx. Il file CSV verrà generato (script/import_scripts/vb_map.csv) durante l’importazione tramite il metodo create_permalink_file. Incolleremo il contenuto del file CSV nel file di mappatura sul server.
Esempio di contenuto del file:
...
/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;
...
Copia l’intero contenuto del file CSV generato in etc/nginx/vb_forum.map sul server di www.example.com.
Modifica nginx.conf
Modifica il file /etc/nginx/nginx.conf per aggiungere questo codice nel blocco http:
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 deve essere regolato in base al numero di URL presenti nel file di mappatura.
Verifica nginx.conf
Verifica il file di configurazione di Nginx:
nginx -c /etc/nginx/nginx.conf -t
Ricarica la configurazione di Nginx per includere le tue modifiche:
sudo systemctl reload nginx
Prova ad accedere a www.example.com/forum; ora dovresti essere reindirizzato a forum.example.com. ![]()
I seguenti tipi di URL verranno gestiti dalla configurazione Nginx sopra:
-
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