# خدمة Discourse من مجلد فرعي، تسجيل الدخول يعيد التوجيه إلى الصفحة الرئيسية

**URL:** https://meta.discourse.org/t/serve-discourse-from-a-subfolder-login-redirects-to-root-path/386619
**Category:** Bug
**Tags:** subfolder
**Created:** [24 أكتوبر 2025، 7:59ص UTC](https://meta.discourse.org/t/serve-discourse-from-a-subfolder-login-redirects-to-root-path/386619 "2025-10-24T07:59:33Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [10 ديسمبر 2025، 10:47م UTC](https://meta.discourse.org/t/serve-discourse-from-a-subfolder-login-redirects-to-root-path/386619/7 "2025-12-10T22:47:37Z")

</div>

@here أعتذر عن ذلك، أعتقد أنني تمكنت من إعادة إنتاج المشكلة وإصلاحها

> <https://github.com/discourse/discourse/pull/36609>
>
> When Discourse is served from a subfolder (e.g., /forum), logging in from the lo…gin page itself would incorrectly redirect users to the root domain (/) instead of the subfolder root (/forum/).
> 
> The issue had two causes:
> 
> 1. The login path check in \`extract\_redirect\_param\` used the Rails \`login\_path\` helper which returns "/login" without the subfolder prefix. When the browser sent the full path "/forum/login", the check \`starts\_with?("/login")\` failed to match, treating it as a valid redirect target instead of rejecting it.
> 
> 2. The \`enter\` method didn't apply the subfolder prefix when falling back to the root path "/".
> 
> Fixed by:
> \- Building the full login path with \`Discourse.base\_path\` for accurate matching in subfolder setups
> \- Wrapping the fallback "/" with \`path()\` in \`enter\` to respect the subfolder configuration
> \- Extracting redirect validation into \`valid\_redirect\_uri?\` for clarity
> 
> Ref - meta/t/386619

---

_[View the full topic](https://meta.discourse.org/t/serve-discourse-from-a-subfolder-login-redirects-to-root-path/386619)._
