Login redirect issue #2261

Closed
opened 2026-02-05 03:29:14 +03:00 by OVERLORD · 4 comments
Owner

Originally created by @samlar on GitHub (May 24, 2021).

Describe the bug
This bug has been fixed in previous version but has recurred, old case: #1048

After logging, a redirection occurs to https://test.se/BookStack/BookStack. Normally is https://test.se/BookStack. And an error message shows up saying Sorry, The page you were looking for could not be found. Still login is successful and there are no other issues. Im using Subdirectory Setup and more about my configuration down below.

Temporary workaround that works for me now is, this is set in apache virtual conf:
Redirect temp /BookStack/BookStack https://test.se/BookStack

Steps To Reproduce
See above.

Expected behavior
No redirection should occur.

Screenshots
N/A

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): v21.04.5
  • PHP Version: PHP 7.3.27-1
  • Hosting Method (Nginx/Apache/Docker): Apache/2.4.38

Additional context
Apache configuration:

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName www.test.se
        ServerAlias test.se

        ServerAdmin test@test.se
        DocumentRoot /var/www/test

        # BookStack Configuration
        Alias "/BookStack" "/var/www/BookStack/public"

        Redirect temp /BookStack/BookStack https://test.se/BookStack

       <Directory "/var/www/BookStack/public">
       Options FollowSymlinks
       AllowOverride None
       Require all granted

       RewriteEngine On
       # Redirect Trailing Slashes If Not A Folder...
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^(.*)/$ /$1 [L,R=301]

       # Handle Front Controller...
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^ index.php [L]
       </Directory>

      <Directory "/var/www/BookStack">
      AllowOverride None
      Require all denied
      </Directory>
      # End BookStack Configuration

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/test.se/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/test.se/privkey.pem
</VirtualHost>
</IfModule>

.env configuration APP_URL=https://test.se/BookStack

Originally created by @samlar on GitHub (May 24, 2021). **Describe the bug** This bug has been fixed in previous version but has recurred, old case: #1048 After logging, a redirection occurs to https://test.se/BookStack/BookStack. Normally is https://test.se/BookStack. And an error message shows up saying **Sorry, The page you were looking for could not be found.** Still login is successful and there are no other issues. Im using Subdirectory Setup and more about my configuration down below. Temporary workaround that works for me now is, this is set in apache virtual conf: ` Redirect temp /BookStack/BookStack https://test.se/BookStack` **Steps To Reproduce** See above. **Expected behavior** No redirection should occur. **Screenshots** N/A **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): v21.04.5 - PHP Version: PHP 7.3.27-1 - Hosting Method (Nginx/Apache/Docker): Apache/2.4.38 **Additional context** Apache configuration: ``` <IfModule mod_ssl.c> <VirtualHost *:443> ServerName www.test.se ServerAlias test.se ServerAdmin test@test.se DocumentRoot /var/www/test # BookStack Configuration Alias "/BookStack" "/var/www/BookStack/public" Redirect temp /BookStack/BookStack https://test.se/BookStack <Directory "/var/www/BookStack/public"> Options FollowSymlinks AllowOverride None Require all granted RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </Directory> <Directory "/var/www/BookStack"> AllowOverride None Require all denied </Directory> # End BookStack Configuration Include /etc/letsencrypt/options-ssl-apache.conf SSLCertificateFile /etc/letsencrypt/live/test.se/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/test.se/privkey.pem </VirtualHost> </IfModule> ``` .env configuration `APP_URL=https://test.se/BookStack`
OVERLORD added the 🐛 Bug🏭 Back-End labels 2026-02-05 03:29:14 +03:00
Author
Owner

@samuelstj commented on GitHub (Jul 22, 2021):

Same problem here. Does anyone have a workaround?

@samuelstj commented on GitHub (Jul 22, 2021): Same problem here. Does anyone have a workaround?
Author
Owner

@ssddanbrown commented on GitHub (Oct 29, 2021):

Some notes from testing just now:

  • Redirect seems to go to the right location when system is public (Where we manually store the uri).
  • Redirect seems to gain duplicated prefix on same instance but when non-public.

From further testing:

  • Removal of custom Request does solve the issue for sub-path setups but that then breaks existing sub-path proxy style setups from my testing.
@ssddanbrown commented on GitHub (Oct 29, 2021): Some notes from testing just now: - Redirect seems to go to the right location when system is public (Where we manually store the uri). - Redirect seems to gain duplicated prefix on same instance but when non-public. From further testing: - Removal of custom `Request` does solve the issue for sub-path setups but that then breaks existing sub-path proxy style setups from my testing.
Author
Owner

@ssddanbrown commented on GitHub (Apr 2, 2022):

Another report in #3361.
Have tested and can reproduce in an apache-based environment after Ubuntu install script usage.
Have assigned this to the next feature release for another attempt at addressing.

Notes from testing

These urls are generated using:

  • Base http host
  • A base URL
  • The path

c816b26f03/Request.php (L1008)

We're overriding the initial one, via getSchemeAndHttpHost, but including the additional base path for sub-path setups.
In such issue scenarios, The $this->getBaseUrl() also returns this sub-path element (At least on Apache, It's detection is complex and likely non-matching in all environments, hence our forced base http host originally).
We likely need to force override both of these elements, so that the custom path is forced as the baseURL and we alter our base http host to just be the host element.


PR open in #3364

@ssddanbrown commented on GitHub (Apr 2, 2022): Another report in #3361. Have tested and can reproduce in an apache-based environment after Ubuntu install script usage. Have assigned this to the next feature release for another attempt at addressing. ### Notes from testing These urls are generated using: - Base http host - A base URL - The path https://github.com/symfony/http-foundation/blob/c816b26f03b6902dba79b352c84a17f53d815f0d/Request.php#L1008 We're overriding the initial one, via `getSchemeAndHttpHost`, but including the additional base path for sub-path setups. In such issue scenarios, The `$this->getBaseUrl()` also returns this sub-path element (At least on Apache, It's detection is complex and likely non-matching in all environments, hence our forced base http host originally). We likely need to force override both of these elements, so that the custom path is forced as the baseURL and we alter our base http host to just be the host element. --- PR open in #3364
Author
Owner

@ssddanbrown commented on GitHub (Apr 24, 2022):

I've now merged in #3364 which will be part of our next feature release, so I'll therefore close this off.
Note, this kind of thing is very environment dependant. If you're coming to this with problems in the future, after the v22.04, please open a new support request issue so we can get details of your environment.

@ssddanbrown commented on GitHub (Apr 24, 2022): I've now merged in #3364 which will be part of our next feature release, so I'll therefore close this off. Note, this kind of thing is very environment dependant. If you're coming to this with problems in the future, after the v22.04, please open a new support request issue so we can get details of your environment.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2261