# إعادة توجيه الفئة إلى عنوان URL خارجي

**URL:** <https://meta.discourse.org/t/redirect-category-to-external-url/85691>\
**Category:** Support\
**Created:** [19 أبريل 2018، 5:32ص UTC](https://meta.discourse.org/t/redirect-category-to-external-url/85691 "2018-04-19T05:32:29Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![cogdog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cogdog/32/116536_2.png) [@cogdog](https://meta.discourse.org/u/cogdog)\
**Post date:** [6 أغسطس 2021، 7:58م UTC](https://meta.discourse.org/t/redirect-category-to-external-url/85691/15 "2021-08-06T19:58:22Z")

</div>

شكرًا لك! كنت بحاجة إلى مجموعة من الفئات الفرعية بحيث تعمل واحدة منها كإعادة توجيه. نظرًا لأن التخصيص الخاص بي يتضمن بالفعل فحصًا لـ `onPageChange()` (يُستخدم لعرض رأس الصفحة فقط في الصفحة الرئيسية)، فإن هذا الحل سيعمل أيضًا، وبالتالي فهو غير مرتبط بشكل ثابت بعنوان URL الكامل للموقع:

```plaintext
<script type="text/discourse-plugin" version="0.8.19">
api.onPageChange((url) => {
       // تحقق مما إذا كنا في الصفحة الرئيسية
        if (url === "/" || url === homeRoute) {
              // قم بإجراءات مخصصة للصفحة الرئيسية
       } else if ( url=== "/c/redirect-politifora" ) {
             // إعادة توجيه الفئة
             window.location.replace( "https://politifora.com/" );
       } else {
             // قم بإجراءات في جميع الصفحات الأخرى، إذا لزم الأمر
       }
});
</script>

```

---

_[View the full topic](https://meta.discourse.org/t/redirect-category-to-external-url/85691)._
