bookstack in subdirectory (e.g. http://mydomain.com/bookstack) #160

Closed
opened 2026-02-04 17:22:30 +03:00 by OVERLORD · 6 comments
Owner

Originally created by @sandreas on GitHub (Sep 12, 2016).

Hey,

i would like to host bookstack in a subdirectory (e.g. http://mydomain.com/bookstack), not http://bookstack.mydomain.com.

  • Login does not work, because of redirect to /login instead of /bookstack/login
  • Css and js-Files to not work because of link to /css/... and /js/... instead of /bookstack/css/...

Is there any config option or possibility to fix this without rewrite rules?

Here is my apache config:

  Alias /bookstack "/var/www/html/third-party-apps/BookStack/public/"
  <Location /bookstack>
    Options +FollowSymLinks
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
  </Location>
Originally created by @sandreas on GitHub (Sep 12, 2016). Hey, i would like to host bookstack in a subdirectory (e.g. http://mydomain.com/bookstack), not http://bookstack.mydomain.com. - Login does not work, because of redirect to /login instead of /bookstack/login - Css and js-Files to not work because of link to /css/... and /js/... instead of /bookstack/css/... Is there any config option or possibility to fix this without rewrite rules? Here is my apache config: ``` Alias /bookstack "/var/www/html/third-party-apps/BookStack/public/" <Location /bookstack> Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </Location> ```
Author
Owner

@ssddanbrown commented on GitHub (Sep 12, 2016):

Hi @sandreas,

Within the .env file is a APP_URL. Try setting that to the URL you expect BookStack to be on and let me know how that goes. For example, set it to:

APP_URL=http://mydomain.com/bookstack
@ssddanbrown commented on GitHub (Sep 12, 2016): Hi @sandreas, Within the `.env` file is a `APP_URL`. Try setting that to the URL you expect BookStack to be on and let me know how that goes. For example, set it to: ``` APP_URL=http://mydomain.com/bookstack ```
Author
Owner

@sandreas commented on GitHub (Sep 12, 2016):

Wow that was quick... Works like expected, thank you very much. But you should definetely provide some documentation of which options are available, or, if it matches the laravel default options, a link to them ;-)

@sandreas commented on GitHub (Sep 12, 2016): Wow that was quick... Works like expected, thank you very much. But you should definetely provide some documentation of which options are available, or, if it matches the laravel default options, a link to them ;-)
Author
Owner

@ssddanbrown commented on GitHub (Sep 12, 2016):

@sandreas Glad that worked, Yeah I totally agree, I've been meaning to document the above in the installation instructions since it was added last month but I've been a little slack on the documentation.

@ssddanbrown commented on GitHub (Sep 12, 2016): @sandreas Glad that worked, Yeah I totally agree, I've been meaning to document the above in the installation instructions since it was added last month but I've been a little slack on the documentation.
Author
Owner

@fontesanta commented on GitHub (Nov 15, 2019):

Can someone help me please?
I'm trying to install Bookstack in a different directory.
When https: //192.168.32.6/wiki.

Unable to access this site
192.168.32.6 refused to connect.
Try it:
Check Connection
Check proxy and firewall
ERR_CONNECTION_REFUSED

I list my settings.
Thanks.

Instalation in /var/www/wiki/BookStack

My .env file

Application URL

Remove the hash below and set a URL if using BookStack behind

a proxy, if using a third-party authentication option.

This must be the root URL that you want to host BookStack on.

All URL's in BookStack will be generated using this value.

APP_URL=https://192.168.32.6/wiki

And my 000-default.conf

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".                                                                                                                                         #Include conf-available/serve-cgi-bin.conf                                                                                                                                              


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

<Directory "/var/www/wiki/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/wiki">
  AllowOverride None
  Require all denied
</Directory>
# End BookStack Configuration

vim: syntax=apache ts=4 sw=4 sts=4 sr noet

@fontesanta commented on GitHub (Nov 15, 2019): Can someone help me please? I'm trying to install Bookstack in a different directory. When https: //192.168.32.6/wiki. -------------------------- Unable to access this site 192.168.32.6 refused to connect. Try it: Check Connection Check proxy and firewall ERR_CONNECTION_REFUSED ------------------------------------------ I list my settings. Thanks. Instalation in /var/www/wiki/BookStack My .env file # Application URL # Remove the hash below and set a URL if using BookStack behind # a proxy, if using a third-party authentication option. # This must be the root URL that you want to host BookStack on. # All URL's in BookStack will be generated using this value. APP_URL=https://192.168.32.6/wiki And my 000-default.conf <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf # BookStack Configuration Alias "/wiki" "/var/www/wiki/Bookstack/public" <Directory "/var/www/wiki/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/wiki"> AllowOverride None Require all denied </Directory> # End BookStack Configuration </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Author
Owner

@bepeters commented on GitHub (Apr 27, 2022):

Hey,

i would like to host bookstack in a subdirectory (e.g. http://mydomain.com/bookstack), not http://bookstack.mydomain.com.

  • Login does not work, because of redirect to /login instead of /bookstack/login
  • Css and js-Files to not work because of link to /css/... and /js/... instead of /bookstack/css/...

Is there any config option or possibility to fix this without rewrite rules?

Here is my apache config:

  Alias /bookstack "/var/www/html/third-party-apps/BookStack/public/"
  <Location /bookstack>
    Options +FollowSymLinks
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
  </Location>

Hi sandreas, I am having a similar issue, though i think my issue is with my apache config. when you say its in your apache config, are you referring to the conf file in you sites-enabled dir? Would you mind showing the whole file?

@bepeters commented on GitHub (Apr 27, 2022): > Hey, > > i would like to host bookstack in a subdirectory (e.g. http://mydomain.com/bookstack), not http://bookstack.mydomain.com. > > * Login does not work, because of redirect to /login instead of /bookstack/login > * Css and js-Files to not work because of link to /css/... and /js/... instead of /bookstack/css/... > > Is there any config option or possibility to fix this without rewrite rules? > > Here is my apache config: > > ``` > Alias /bookstack "/var/www/html/third-party-apps/BookStack/public/" > <Location /bookstack> > Options +FollowSymLinks > RewriteEngine On > > RewriteCond %{REQUEST_FILENAME} !-d > RewriteCond %{REQUEST_FILENAME} !-f > RewriteRule ^ index.php [L] > </Location> > ``` Hi sandreas, I am having a similar issue, though i think my issue is with my apache config. when you say its in your apache config, are you referring to the conf file in you sites-enabled dir? Would you mind showing the whole file?
Author
Owner

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

@bepeters This thread is almost 6 years old.
We now have documentation to help on this subject here: https://www.bookstackapp.com/docs/admin/subdirectory-setup/
Note, we don't support nor advise your BookStack install directory being within another website directory.
If /var/www/html or /var/www/html/third-party-apps is exposed to the web already, the BookStack files should be moved elsewhere. Only the public directory of the BookStack install directory should be exposed to the web.

@ssddanbrown commented on GitHub (Apr 28, 2022): @bepeters This thread is almost 6 years old. We now have documentation to help on this subject here: https://www.bookstackapp.com/docs/admin/subdirectory-setup/ Note, we don't support nor advise your BookStack install directory being within another website directory. If `/var/www/html` or `/var/www/html/third-party-apps` is exposed to the web already, the BookStack files should be moved elsewhere. Only the `public` directory of the BookStack install directory should be exposed to the web.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#160