Using BookStack in Subdirectory leads into "Page not found" #4807

Closed
opened 2026-02-05 09:17:34 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @twindscheif on GitHub (Jun 2, 2024).

Describe the Bug

First of all: I love BookStack and i already installed several instances using default parameters.
In this case i need to use a Subdirectory for the first time.

Installed a fresh BookStack v24.05.1-instance on latest Ubuntu Server 24 LTS with Install-Script.
If accessing the Subdirectory it fails with "Page not found."
Without using Subdirectory it works, which means, i can logon and work within BookStack.

Target URL: http://portal.mydomain.local/bookstack
Bookstack Install-Path: /var/www/bookstack

When using subdirectory (/bookstack) like used in the configuration example (https://www.bookstackapp.com/docs/admin/subdirectory-setup/)
i'm redirected to /bookstack/login and always get "Page not found"-Error.

image

/var/www/bookstack/.env

# This file, when named as ".env" in the root of your BookStack install
# folder, is used for the core configuration of the application.
# By default this file contains the most common required options but
# a full list of options can be found in the '.env.example.complete' file.

# NOTE: If any of your values contain a space or a hash you will need to
# wrap the entire value in quotes. (eg. MAIL_FROM_NAME="BookStack Mailer")

# Application environment
# Can be 'production', 'development', 'testing' or 'demo'
APP_ENV=production

# Sets application language to english
APP_LANG=en

#disable auto language
APP_AUTO_LANG_PUBLIC=false

# Application key
# Used for encryption where needed.
# Run `php artisan key:generate` to generate a valid key.
APP_KEY=base64:<Removed for Security>

# Application URL
# This must be the root URL that you want to host BookStack on.
# All URLs in BookStack will be generated using this value
# to ensure URLs generated are consistent and secure.
# If you change this in the future you may need to run a command
# to update stored URLs in the database. Command example:
# php artisan bookstack:update-url https://old.example.com https://new.example.com
APP_URL=http://portal.mydomain.local/bookstack

# Database details
DB_HOST=localhost
DB_DATABASE=bookstack
DB_USERNAME=bookstack
DB_PASSWORD=<Removed for Security>

Installed Apache modules:
sudo a2enmod ssl
sudo a2enmod headers
sudo a2enmod rewrite

/etc/apache2/sites-available/bookstack.conf

<VirtualHost *:80>

        ServerName portal.mydomain.local
        DocumentRoot /var/www/bookstack/public/

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

    <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

        ErrorLog error.log
        CustomLog access.log combined

</VirtualHost>

Restarted apache service via
sudo systemctl restart apache2

Cleared Browser Cache

Steps to Reproduce

  1. Browse http://portal.mydomain.local/bookstack with Firefox

Expected Behaviour

If accessing the main page http://portal.mydomain.local/bookstack i expect to see the login-page of BookStack

Screenshots or Additional Context

No response

Browser Details

Firefox 126 on Windows Server 2019

Exact BookStack Version

v24.05.1

Originally created by @twindscheif on GitHub (Jun 2, 2024). ### Describe the Bug First of all: I love BookStack and i already installed several instances using default parameters. In this case i need to use a Subdirectory for the first time. Installed a fresh BookStack v24.05.1-instance on latest Ubuntu Server 24 LTS with Install-Script. If accessing the Subdirectory it fails with "Page not found." Without using Subdirectory it works, which means, i can logon and work within BookStack. Target URL: http://portal.mydomain.local/bookstack Bookstack Install-Path: /var/www/bookstack When using subdirectory (/bookstack) like used in the configuration example (https://www.bookstackapp.com/docs/admin/subdirectory-setup/) i'm redirected to /bookstack/login and always get "Page not found"-Error. ![image](https://github.com/BookStackApp/BookStack/assets/39372993/bf60c862-46f0-4ebe-a8f4-1778d3d3bb59) **/var/www/bookstack/.env** ``` # This file, when named as ".env" in the root of your BookStack install # folder, is used for the core configuration of the application. # By default this file contains the most common required options but # a full list of options can be found in the '.env.example.complete' file. # NOTE: If any of your values contain a space or a hash you will need to # wrap the entire value in quotes. (eg. MAIL_FROM_NAME="BookStack Mailer") # Application environment # Can be 'production', 'development', 'testing' or 'demo' APP_ENV=production # Sets application language to english APP_LANG=en #disable auto language APP_AUTO_LANG_PUBLIC=false # Application key # Used for encryption where needed. # Run `php artisan key:generate` to generate a valid key. APP_KEY=base64:<Removed for Security> # Application URL # This must be the root URL that you want to host BookStack on. # All URLs in BookStack will be generated using this value # to ensure URLs generated are consistent and secure. # If you change this in the future you may need to run a command # to update stored URLs in the database. Command example: # php artisan bookstack:update-url https://old.example.com https://new.example.com APP_URL=http://portal.mydomain.local/bookstack # Database details DB_HOST=localhost DB_DATABASE=bookstack DB_USERNAME=bookstack DB_PASSWORD=<Removed for Security> ``` Installed Apache modules: sudo a2enmod ssl sudo a2enmod headers sudo a2enmod rewrite /etc/apache2/sites-available/bookstack.conf ``` <VirtualHost *:80> ServerName portal.mydomain.local DocumentRoot /var/www/bookstack/public/ # BookStack Configuration Alias "/bookstack" "/var/www/bookstack/public" <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 ErrorLog error.log CustomLog access.log combined </VirtualHost> ``` Restarted apache service via sudo systemctl restart apache2 Cleared Browser Cache ### Steps to Reproduce 1. Browse http://portal.mydomain.local/bookstack with Firefox ### Expected Behaviour If accessing the main page http://portal.mydomain.local/bookstack i expect to see the login-page of BookStack ### Screenshots or Additional Context _No response_ ### Browser Details Firefox 126 on Windows Server 2019 ### Exact BookStack Version v24.05.1
OVERLORD added the 🐛 Bug label 2026-02-05 09:17:34 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Jun 3, 2024):

Hi @twindscheif,
Within your /etc/apache2/sites-available/bookstack.conf file, can you update the DocumentRoot /var/www/bookstack/public/ option so the path is in a completely different location to the BookStack setup? (Do not use the /var/www/bookstack/ path at all, so something like /var/www/other-folder/).
Then restart apache and check again.

@ssddanbrown commented on GitHub (Jun 3, 2024): Hi @twindscheif, Within your `/etc/apache2/sites-available/bookstack.conf` file, can you update the `DocumentRoot /var/www/bookstack/public/` option so the path is in a completely different location to the BookStack setup? (Do not use the `/var/www/bookstack/` path at all, so something like `/var/www/other-folder/`). Then restart apache and check again.
Author
Owner

@twindscheif commented on GitHub (Jun 3, 2024):

Hi @ssddanbrown,

you are a genius :). After Changing the DocumentRoot to another folder outside the BookStack-installation (or even comment out DocumentRoot) it works perfectly.

Thank you so much

@twindscheif commented on GitHub (Jun 3, 2024): Hi @ssddanbrown, you are a genius :). After Changing the DocumentRoot to another folder outside the BookStack-installation (or even comment out DocumentRoot) it works perfectly. Thank you so much
Author
Owner

@ssddanbrown commented on GitHub (Jun 4, 2024):

Good to hear that worked, and thanks for the support and PR!

@ssddanbrown commented on GitHub (Jun 4, 2024): Good to hear that worked, and thanks for the support and PR!
Author
Owner

@ghost commented on GitHub (Aug 19, 2024):

Good to hear that worked, and thanks for the support and PR!

Not sure if this is the place to ask, but why does this work? Either just randomly assigning document source to another folder or commenting it out alltogether. Just curious.

Thx!

@ghost commented on GitHub (Aug 19, 2024): > Good to hear that worked, and thanks for the support and PR! Not sure if this is the place to ask, but why does this work? Either just randomly assigning document source to another folder or commenting it out alltogether. Just curious. Thx!
Author
Owner

@ssddanbrown commented on GitHub (Aug 19, 2024):

@blackstone879 I'm not sure to be honest, just assumed that attempting to do that within the same directory causes some logical overlaps (or recursions) into where Apache has to look.

@ssddanbrown commented on GitHub (Aug 19, 2024): @blackstone879 I'm not sure to be honest, just assumed that attempting to do that within the same directory causes some logical overlaps (or recursions) into where Apache has to look.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#4807