Listing view toggle redirects do not take APP_URL into account #1197

Closed
opened 2026-02-05 00:13:25 +03:00 by OVERLORD · 11 comments
Owner

Originally created by @nekromoff on GitHub (May 23, 2019).

Describe the bug
e.g.: /books/faktur%c3%a1cia?shelf=2

Steps To Reproduce
Steps to reproduce the behavior:

  1. Create URL with extended ASCII chars
  2. URLs not working after upgrade
    Expected behavior
    URL working after upgrade

Screenshots
If applicable, add screenshots to help explain your problem.

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): 0.26.1
  • PHP Version: 7.2
  • Hosting Method (Nginx/Apache/Docker): Apache

Additional context
Add any other context about the problem here.

Originally created by @nekromoff on GitHub (May 23, 2019). **Describe the bug** e.g.: /books/faktur%c3%a1cia?shelf=2 **Steps To Reproduce** Steps to reproduce the behavior: 1. Create URL with extended ASCII chars 2. URLs not working after upgrade **Expected behavior** URL working after upgrade **Screenshots** If applicable, add screenshots to help explain your problem. **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): 0.26.1 - PHP Version: 7.2 - Hosting Method (Nginx/Apache/Docker): Apache **Additional context** Add any other context about the problem here.
OVERLORD added the 🐛 Bug🔍 Pending Validation labels 2026-02-05 00:13:25 +03:00
Author
Owner

@nekromoff commented on GitHub (May 23, 2019):

OK, I can now narrow the bug to the List View, where on the homepage query parameter is added, such as:
books/administrat%C3%ADva/?shelf=2

These URLs are all broken with 404 pages.

@nekromoff commented on GitHub (May 23, 2019): OK, I can now narrow the bug to the List View, where on the homepage query parameter is added, such as: books/administrat%C3%ADva/?shelf=2 These URLs are all broken with 404 pages.
Author
Owner

@ssddanbrown commented on GitHub (May 25, 2019):

Hi @nekromoff,

Just tried to re-produce this but without success.
Are you able to reproduce this issue on the BookStack demo instance?

@ssddanbrown commented on GitHub (May 25, 2019): Hi @nekromoff, Just tried to re-produce this but without success. Are you able to reproduce this issue on the [BookStack demo instance](https://demo.bookstackapp.com/login?email=admin@example.com&password=password)?
Author
Owner

@nekromoff commented on GitHub (Jun 6, 2019):

.htaccess:

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

    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]
</IfModule>

List view enabled, any click to books will lead to:

URL:
image

image

@nekromoff commented on GitHub (Jun 6, 2019): .htaccess: ``` <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> 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] </IfModule> ``` List view enabled, any click to books will lead to: URL: ![image](https://user-images.githubusercontent.com/8550349/59030370-15c5ca80-8861-11e9-8fc4-c5743f9c2af0.png) ![image](https://user-images.githubusercontent.com/8550349/59030377-1a8a7e80-8861-11e9-9b7e-640a28e4b390.png)
Author
Owner

@nekromoff commented on GitHub (Jun 6, 2019):

OK, I have identified the problem.

Existing serving directory is:
domain.com/wiki/public/books/...

I get redirected to:
domain.com/books/...

So, there is issue with that.

.env:

APP_URL=https://domain.com/wiki/public
@nekromoff commented on GitHub (Jun 6, 2019): OK, I have identified the problem. Existing serving directory is: domain.com/wiki/public/books/... I get redirected to: domain.com/books/... So, there is issue with that. .env: ``` APP_URL=https://domain.com/wiki/public ```
Author
Owner

@ssddanbrown commented on GitHub (Jun 6, 2019):

@nekromoff Do other URL's in the application work? or is it just the books listing?

Just as a warning, since you've got public in your APP_URL, If you're serving BookStack as a sub-folder of another website, this will probably be insecure since many more files would be exposed to the web server than should be.

Documentation for this kind of set-up can be found in the docs here: https://www.bookstackapp.com/docs/admin/subdirectory-setup/

@ssddanbrown commented on GitHub (Jun 6, 2019): @nekromoff Do other URL's in the application work? or is it just the books listing? Just as a warning, since you've got `public` in your APP_URL, If you're serving BookStack as a sub-folder of another website, this will probably be insecure since many more files would be exposed to the web server than should be. Documentation for this kind of set-up can be found in the docs here: https://www.bookstackapp.com/docs/admin/subdirectory-setup/
Author
Owner

@nekromoff commented on GitHub (Jun 6, 2019):

Other URLs work fine, this seems to be problem with a href linking in
that particular case, when list view is selected in the shelves page.

@nekromoff commented on GitHub (Jun 6, 2019): Other URLs work fine, this seems to be problem with `a href` linking in that particular case, when list view is selected in the `shelves` page.
Author
Owner

@ssddanbrown commented on GitHub (Jun 6, 2019):

@nekromoff Ah, Okay, So it's only on view change?

If so I'll update the original issue title since this sounds like it's become something different.

@ssddanbrown commented on GitHub (Jun 6, 2019): @nekromoff Ah, Okay, So it's only on view change? If so I'll update the original issue title since this sounds like it's become something different.
Author
Owner

@nekromoff commented on GitHub (Jun 6, 2019):

It has become something else, sorry for the misleading start, I have only pinpointed the exact issue recently.

@nekromoff commented on GitHub (Jun 6, 2019): It has become something else, sorry for the misleading start, I have only pinpointed the exact issue recently.
Author
Owner

@ssddanbrown commented on GitHub (Jun 6, 2019):

@nekromoff No worries, I'll update the title. Think I can see where this is caused, Will mark for next release to ensure it's looked at.

Just as an added note, please check your setup as per my earlier comment. If you can go to https://www.domain.com/wiki/.env and the browser downloads your .env file then that's a big concern.

@ssddanbrown commented on GitHub (Jun 6, 2019): @nekromoff No worries, I'll update the title. Think I can see where this is caused, Will mark for next release to ensure it's looked at. Just as an added note, please check your setup as per my earlier comment. If you can go to `https://www.domain.com/wiki/.env` and the browser downloads your `.env` file then that's a big concern.
Author
Owner

@nekromoff commented on GitHub (Jun 6, 2019):

I understand, thanks for the heads up!

On Thu, Jun 6, 2019 at 4:13 PM Dan Brown notifications@github.com wrote:

@nekromoff https://github.com/nekromoff No worries, I'll update the
title. Think I can see where this is caused, Will mark for next release to
ensure it's looked at.

Just as an added note, please check your setup as per my earlier comment.
If you can go to https://www.domain.com/wiki/.env and the browser
downloads your .env file then that's a big concern.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/BookStackApp/BookStack/issues/1459?email_source=notifications&email_token=ACBHPTP4UMPIDICO2O6IYKTPZELQ7A5CNFSM4HPAFHG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXC7EXA#issuecomment-499511900,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACBHPTL3DF3QVZPNDGJG6NLPZELQ7ANCNFSM4HPAFHGQ
.

@nekromoff commented on GitHub (Jun 6, 2019): I understand, thanks for the heads up! On Thu, Jun 6, 2019 at 4:13 PM Dan Brown <notifications@github.com> wrote: > @nekromoff <https://github.com/nekromoff> No worries, I'll update the > title. Think I can see where this is caused, Will mark for next release to > ensure it's looked at. > > Just as an added note, please check your setup as per my earlier comment. > If you can go to https://www.domain.com/wiki/.env and the browser > downloads your .env file then that's a big concern. > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/BookStackApp/BookStack/issues/1459?email_source=notifications&email_token=ACBHPTP4UMPIDICO2O6IYKTPZELQ7A5CNFSM4HPAFHG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXC7EXA#issuecomment-499511900>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/ACBHPTL3DF3QVZPNDGJG6NLPZELQ7ANCNFSM4HPAFHGQ> > . >
Author
Owner

@ssddanbrown commented on GitHub (Aug 4, 2019):

Significant changes have been made to URL generation in 4b0c4e621a which should now fix this. I have tested this scenario on a development instance and it appears to work but this kind of thing can be setup/system dependant.

These changes will be in the next release, v0.27. I will close this request in the meantime. If you continue to experience issues after that version is released please open a new issue referencing this one.

@ssddanbrown commented on GitHub (Aug 4, 2019): Significant changes have been made to URL generation in 4b0c4e621a55d5f6f59de7451c7442a4571ad72e which should now fix this. I have tested this scenario on a development instance and it appears to work but this kind of thing can be setup/system dependant. These changes will be in the next release, v0.27. I will close this request in the meantime. If you continue to experience issues after that version is released please open a new issue referencing this one.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1197