هل تخطط للترحيل من vBulletin إلى Discourse وتريد إعادة توجيه عناوين URL القديمة من vBulletin إلى عناوين URL الجديدة في Discourse؟ تابع القراءة!
إذا كان عنوان URL الأساسي في المنتدى القديم والمنتدى الجديد هو نفسه، فيجب عليك اتباع هذا الدليل بدلاً من ذلك:
Redirect old forum URLs to new Discourse URLs using permalinks
في هذا الدليل، سنفترض ما يلي:
-
عنوان URL الأساسي لـ vBulletin:
www.example.com/forum -
عنوان URL الأساسي لـ Discourse:
forum.example.com -
خادم Nginx لـ
www.example.com
لنبدأ!
إنشاء ملف خريطة Nginx
لإعداد إعادة توجيه الفئات والمواضيع، سنستخدم وحدة map في Nginx. سيتم إنشاء ملف CSV (script/import_scripts/vb_map.csv) أثناء تنفيذ عملية الاستيراد عبر دالة create_permalink_file. سنقوم بلصق محتوى ملف CSV في ملف الخريطة على الخادم.
محتويات عينة للملف:
...
/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;
...
انسخ المحتوى الكامل لملف CSV المُنشأ إلى etc/nginx/vb_forum.map على خادم www.example.com.
تعديل nginx.conf
قم بتعديل ملف /etc/nginx/nginx.conf لإضافة هذا الكود في كتلة 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 بناءً على عدد عناوين URL الموجودة في ملف الخريطة.
التحقق من nginx.conf
تحقق من ملف إعدادات Nginx الخاص بك:
nginx -c /etc/nginx/nginx.conf -t
أعد تحميل إعدادات Nginx لتشمل التغييرات التي أجريتها:
sudo systemctl reload nginx
حاول الوصول إلى www.example.com/forum، ويجب أن يتم إعادة توجيهك الآن إلى forum.example.com. ![]()
سيتم التعامل مع أنواع عناوين URL التالية بواسطة إعدادات Nginx أعلاه:
-
www.example.com/forum–\u003eforum.example.com -
www.example.com/forum/forumdisplay.php?6–\u003eforum.example.com/c/games -
www.example.com/forum/forumdisplay.php?6-Games–\u003eforum.example.com/c/games -
www.example.com/forum/forumdisplay.php?f=6–\u003eforum.example.com/c/games -
www.example.com/forum/showthread.php?2–\u003eforum.example.com/t/topic-slug/23 -
www.example.com/forum/showthread.php?2-topic-slug–\u003eforum.example.com/t/topic-slug/23 -
www.example.com/forum/showthread.php?t=2–\u003eforum.example.com/t/topic-slug/23