XAMPP/Apache Subdirectory config not working for homepage #4224

Closed
opened 2026-02-05 08:17:19 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @13robin37 on GitHub (Sep 20, 2023).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Sadly I am unable to get the subdirectory config for the homepage to work. BookStack works just fine in all aspects except the homepage which isn't rendered properly (error 404).

When I try to access subpages, books, settings, etc. everything is working as expected. When I try to access https://domain/bookstack it displays "page" not found. When I access https://domain/bookstack/index.php directly the desired homepage is displayed. I've played with the homepage settings under customization without any effect (displaying shelves, custom page, books as the homepage).

APP_URL is set to https://domain/bookstack

Current subdir config within the httpd-ssl.conf (from https://www.bookstackapp.com/docs/admin/subdirectory-setup/):

# BookStack Configuration
    Alias "/bookstack" "D:/xampp/webdir/bookstack/public"
    <Directory "D:/xampp/webdir/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 "D:/xampp/webdir/bookstack/">
        AllowOverride None
        Require all denied
    </Directory>
    # End BookStack Configuration

I have other applications under D:/xampp/htdocs/ so I moved it to another path to avoid some mixup with .htaccess directives.

Current .htaccess under D:/xampp/webdir/bookstack/public (even tested adding a RewriteRule there, otherwise stock):

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On
	#Subdirectory Test
	#RewriteBase /bookstack

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

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

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Tested with APP_DEBUG=true as well but BookStack doesn't throw any errors so I think this is based on some config error on my side. Other hosted apps work just fine, I even run other apps in Directories which don't have any issues. Any idea?

Exact BookStack Version

v23.08.2

Log Content

access.log:
"GET /bookstack/ HTTP/2.0" 404 7372

error.log with LogLevel alert rewrite:trace6:

[perdir D:/xampp/webdir/bookstack/public/] strip per-dir prefix: D:/xampp/webdir/bookstack/public/ -> , referer: https://domain/bookstack/
[perdir D:/xampp/webdir/bookstack/public/] applying pattern '^(.*)/$' to uri '', referer: https://domain/bookstack/
[perdir D:/xampp/webdir/bookstack/public/] strip per-dir prefix: D:/xampp/webdir/bookstack/public/ -> , referer: https://domain/bookstack/
[perdir D:/xampp/webdir/bookstack/public/] applying pattern '^' to uri '', referer: https://domain/bookstack/
[perdir D:/xampp/webdir/bookstack/public/] RewriteCond: input='D:/xampp/webdir/bookstack/public/' pattern='!-d' => not-matched, referer: https://domain/bookstack/
[perdir D:/xampp/webdir/bookstack/public/] pass through D:/xampp/webdir/bookstack/public/, referer: https://domain/bookstack/
[perdir D:/xampp/webdir/bookstack/public/] strip per-dir prefix: D:/xampp/webdir/bookstack/public/index.php -> index.php, referer: https://domain/bookstack/
[perdir D:/xampp/webdir/bookstack/public/] applying pattern '^' to uri 'index.php', referer: https://domain/bookstack/
[perdir D:/xampp/webdir/bookstack/public/] RewriteCond: input='D:/xampp/webdir/bookstack/public/index.php' pattern='!-d' => matched, referer: https://domain/bookstack/
[perdir D:/xampp/webdir/bookstack/public/] RewriteCond: input='D:/xampp/webdir/bookstack/public/index.php' pattern='!-f' => not-matched, referer: https://domain/bookstack/
[perdir D:/xampp/webdir/bookstack/public/] pass through D:/xampp/webdir/bookstack/public/index.php, referer: https://domain/bookstack/

Hosting Environment

Windows with XAMPP.
Apache/2.4.56 (Win64)
OpenSSL/1.1.1t PHP/8.1.17

Originally created by @13robin37 on GitHub (Sep 20, 2023). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario Sadly I am unable to get the subdirectory config for the homepage to work. BookStack works just fine in all aspects except the homepage which isn't rendered properly (error 404). When I try to access subpages, books, settings, etc. everything is working as expected. When I try to access https://domain/bookstack it displays "page" not found. When I access https://domain/bookstack/index.php directly the desired homepage is displayed. I've played with the homepage settings under customization without any effect (displaying shelves, custom page, books as the homepage). APP_URL is set to https://domain/bookstack Current subdir config within the httpd-ssl.conf (from https://www.bookstackapp.com/docs/admin/subdirectory-setup/): ```apache # BookStack Configuration Alias "/bookstack" "D:/xampp/webdir/bookstack/public" <Directory "D:/xampp/webdir/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 "D:/xampp/webdir/bookstack/"> AllowOverride None Require all denied </Directory> # End BookStack Configuration ``` I have other applications under D:/xampp/htdocs/ so I moved it to another path to avoid some mixup with .htaccess directives. Current .htaccess under D:/xampp/webdir/bookstack/public (even tested adding a RewriteRule there, otherwise stock): ```apache <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On #Subdirectory Test #RewriteBase /bookstack # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Send Requests To Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> ``` Tested with APP_DEBUG=true as well but BookStack doesn't throw any errors so I think this is based on some config error on my side. Other hosted apps work just fine, I even run other apps in Directories which don't have any issues. Any idea? ### Exact BookStack Version v23.08.2 ### Log Content access.log: `"GET /bookstack/ HTTP/2.0" 404 7372` error.log with _LogLevel alert rewrite:trace6_: ``` [perdir D:/xampp/webdir/bookstack/public/] strip per-dir prefix: D:/xampp/webdir/bookstack/public/ -> , referer: https://domain/bookstack/ [perdir D:/xampp/webdir/bookstack/public/] applying pattern '^(.*)/$' to uri '', referer: https://domain/bookstack/ [perdir D:/xampp/webdir/bookstack/public/] strip per-dir prefix: D:/xampp/webdir/bookstack/public/ -> , referer: https://domain/bookstack/ [perdir D:/xampp/webdir/bookstack/public/] applying pattern '^' to uri '', referer: https://domain/bookstack/ [perdir D:/xampp/webdir/bookstack/public/] RewriteCond: input='D:/xampp/webdir/bookstack/public/' pattern='!-d' => not-matched, referer: https://domain/bookstack/ [perdir D:/xampp/webdir/bookstack/public/] pass through D:/xampp/webdir/bookstack/public/, referer: https://domain/bookstack/ [perdir D:/xampp/webdir/bookstack/public/] strip per-dir prefix: D:/xampp/webdir/bookstack/public/index.php -> index.php, referer: https://domain/bookstack/ [perdir D:/xampp/webdir/bookstack/public/] applying pattern '^' to uri 'index.php', referer: https://domain/bookstack/ [perdir D:/xampp/webdir/bookstack/public/] RewriteCond: input='D:/xampp/webdir/bookstack/public/index.php' pattern='!-d' => matched, referer: https://domain/bookstack/ [perdir D:/xampp/webdir/bookstack/public/] RewriteCond: input='D:/xampp/webdir/bookstack/public/index.php' pattern='!-f' => not-matched, referer: https://domain/bookstack/ [perdir D:/xampp/webdir/bookstack/public/] pass through D:/xampp/webdir/bookstack/public/index.php, referer: https://domain/bookstack/ ``` ### Hosting Environment Windows with XAMPP. Apache/2.4.56 (Win64) OpenSSL/1.1.1t PHP/8.1.17
OVERLORD added the 🐕 Support label 2026-02-05 08:17:19 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Sep 26, 2023):

Hi @13robin37,
Just tested subdirectory usage on a Windows 10 VM and XAMPP, and all worked fine and as expected.

Full VirtualHost Config Used

<VirtualHost *:80>

	ServerName bs.test
	DocumentRoot "C:/xampp/htdocs/static"

    # BookStack Configuration
    Alias "/bookstack" "C:/xampp/webdir/bookstack/public"

    <Directory "C:/xampp/webdir/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 "C:/xampp/webdir/bookstack">
      AllowOverride None
      Require all denied
    </Directory>
    # End BookStack Configuration

	ErrorLog error.log
	CustomLog access.log combined

</VirtualHost>

I thought maybe your issue could be the trailing slash on the second directory block, but I wasn't able to replicate your issue via adding that to my config.

  • What else is in the same configuration block for this virtualhost? Just wondering if there's other configuration at play that's interfering with the BookStack homepage path.
  • In the default web root folder, for the domain/hostname, make sure there's no bookstack folder left there that could be interfering.
@ssddanbrown commented on GitHub (Sep 26, 2023): Hi @13robin37, Just tested subdirectory usage on a Windows 10 VM and XAMPP, and all worked fine and as expected. <details><summary>Full VirtualHost Config Used</summary> <p> ```apache <VirtualHost *:80> ServerName bs.test DocumentRoot "C:/xampp/htdocs/static" # BookStack Configuration Alias "/bookstack" "C:/xampp/webdir/bookstack/public" <Directory "C:/xampp/webdir/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 "C:/xampp/webdir/bookstack"> AllowOverride None Require all denied </Directory> # End BookStack Configuration ErrorLog error.log CustomLog access.log combined </VirtualHost> ``` </p> </details> I thought maybe your issue could be the trailing slash on the second directory block, but I wasn't able to replicate your issue via adding that to my config. - What else is in the same configuration block for this virtualhost? Just wondering if there's other configuration at play that's interfering with the BookStack homepage path. - In the default web root folder, for the domain/hostname, make sure there's no `bookstack` folder left there that could be interfering.
Author
Owner

@13robin37 commented on GitHub (Sep 27, 2023):

Yea, basically same config as I have used.

Regarding config block, I have multiple aliases under that same domain which all work fine.
No folders under xampp/htdocs as well.

As I plan to migrate this to a container environment in the near future anyway, that problem should be solved then.

For now I've set
Redirectmatch 301 ^/bookstack/$ https://domain/bookstack/index.php
to fix this the dirty way. Let's close this for now, most likely an issue with the vhost config at some point but I don't want to waste your time on that. Thank you for your help!

@13robin37 commented on GitHub (Sep 27, 2023): Yea, basically same config as I have used. Regarding config block, I have multiple aliases under that same domain which all work fine. No folders under xampp/htdocs as well. As I plan to migrate this to a container environment in the near future anyway, that problem should be solved then. For now I've set ` Redirectmatch 301 ^/bookstack/$ https://domain/bookstack/index.php ` to fix this the dirty way. Let's close this for now, most likely an issue with the vhost config at some point but I don't want to waste your time on that. Thank you for your help!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#4224