Cannot load login page because of rewrite rules #1158

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

Originally created by @altucor on GitHub (Apr 26, 2019).

Describe the bug
I've installed BookStack like described in manual part of this guide: https://www.bookstackapp.com/docs/admin/installation/#manual
So problem: I cannot see login page after installation. It tries redirect me to: http://domain.com/login but instead of login page i've got "Your browser sent a request that this server could not understand".
After several hours of debugging i found the problem in this line: "RewriteRule ^ index.php [L]".
When this line is commented i can see some kind of page, but it's corrupted because i have index.php in all url's which points to images, styles and other.

image

When this line is uncomented(active) then i always got this message "Your browser sent a request that this server could not understand. Tested on Chrome and Firefox.

So at least i know problem in rewrite rules, but i don't know why they come and how to fix them. Also as you can see i have lower version of php, but i think it is not related to current problem.

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): from version file v0.25.5
  • PHP Version: PHP 7.0.33-0ubuntu0.16.04.4 (cli) ( NTS )
  • Hosting Method: Apache
Originally created by @altucor on GitHub (Apr 26, 2019). **Describe the bug** I've installed BookStack like described in manual part of this guide: https://www.bookstackapp.com/docs/admin/installation/#manual So problem: I cannot see login page after installation. It tries redirect me to: http://domain.com/login but instead of login page i've got "Your browser sent a request that this server could not understand". After several hours of debugging i found the problem in this line: "RewriteRule ^ index.php [L]". When this line is commented i can see some kind of page, but it's corrupted because i have index.php in all url's which points to images, styles and other. ![image](https://user-images.githubusercontent.com/31515257/56780379-be572800-67e7-11e9-9051-06a7ac50f74a.png) When this line is uncomented(active) then i always got this message "Your browser sent a request that this server could not understand. Tested on Chrome and Firefox. So at least i know problem in rewrite rules, but i don't know why they come and how to fix them. Also as you can see i have lower version of php, but i think it is not related to current problem. **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): from version file v0.25.5 - PHP Version: PHP 7.0.33-0ubuntu0.16.04.4 (cli) ( NTS ) - Hosting Method: Apache
OVERLORD added the 🐕 Support label 2026-02-05 00:06:09 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Apr 26, 2019):

Hi @altucor,

To be able to help we're going to need a bit more information on your setup.

  • Where have you placed the rewrite rules? In the virtual host config or have you modified a .htaccess file?
  • Are you able to supply your apache virtual host configuration?
  • What is your operating system?
  • Do you have apache mod_rewrite enabled?
@ssddanbrown commented on GitHub (Apr 26, 2019): Hi @altucor, To be able to help we're going to need a bit more information on your setup. * Where have you placed the rewrite rules? In the virtual host config or have you modified a .htaccess file? * Are you able to supply your apache virtual host configuration? * What is your operating system? * Do you have apache mod_rewrite enabled?
Author
Owner

@altucor commented on GitHub (Apr 26, 2019):

First of all thanks for your help.

Place: I tried both ways, default htaccess and virtual host. Also tried to use other rewrite rules, now all is rolled back to original state.

OS: Ubuntu 16.04.6 LTS (GNU/Linux 4.10.0-42-generic x86_64)

Rewrite module:
sudo a2enmod rewrite
Module rewrite already enabled

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName domain.com
    ServerAlias domain.com
    DocumentRoot /var/www/domain.com/public/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # Also tried run with this commented block
    #<Directory "/var/www/domain.com/public/">
    #    AllowOverride All
    #</Directory>

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    #RewriteRule ^ index.php [L]
    #RewriteRule (.+) index.php?p=$1 [QSA,L] # also tried this line instead of line above
</VirtualHost>
@altucor commented on GitHub (Apr 26, 2019): First of all thanks for your help. Place: I tried both ways, default htaccess and virtual host. Also tried to use other rewrite rules, now all is rolled back to original state. OS: Ubuntu 16.04.6 LTS (GNU/Linux 4.10.0-42-generic x86_64) Rewrite module: sudo a2enmod rewrite Module rewrite already enabled ``` <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName domain.com ServerAlias domain.com DocumentRoot /var/www/domain.com/public/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # Also tried run with this commented block #<Directory "/var/www/domain.com/public/"> # AllowOverride All #</Directory> Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f #RewriteRule ^ index.php [L] #RewriteRule (.+) index.php?p=$1 [QSA,L] # also tried this line instead of line above </VirtualHost> ```
Author
Owner

@ssddanbrown commented on GitHub (Apr 26, 2019):

@altucor Thanks for the info. It might be a small while before I have a chance to explore this.

Alternatively, Below is the virtualhost configuration from our install script, may provide some hints for you. Is for Ubuntu 18.04 but I don't think apache changed that much since 16.04.

82b0818eaa/scripts/installation-ubuntu-18.04.sh (L75-L111)

@ssddanbrown commented on GitHub (Apr 26, 2019): @altucor Thanks for the info. It might be a small while before I have a chance to explore this. Alternatively, Below is the virtualhost configuration from our install script, may provide some hints for you. Is for Ubuntu 18.04 but I don't think apache changed that much since 16.04. https://github.com/BookStackApp/devops/blob/82b0818eaa4f1b1f79927c3481a145d11ddcb114/scripts/installation-ubuntu-18.04.sh#L75-L111
Author
Owner

@altucor commented on GitHub (Apr 26, 2019):

Ok, thanks, i will try it.

@altucor commented on GitHub (Apr 26, 2019): Ok, thanks, i will try it.
Author
Owner

@altucor commented on GitHub (Apr 26, 2019):

Looks like it works, i just placed config which you shows above. Thank you, solved.

@altucor commented on GitHub (Apr 26, 2019): Looks like it works, i just placed config which you shows above. Thank you, solved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1158