Fixed Exception to “Use full friendly URLs”

Aivaras

Well-known member
Affected version
2.2.10 Patch 1
To reproduce:
  1. Check “Use full friendly URLs” in ACP > Setup > Options > Basic options;
  2. Ensure .htaccess with appropriate rules is available in the server;
  3. Uncheck “Board is active” in ACP > Setup > Options > Board active;
  4. Click the link to the forum in the upper left corner of the ACP;
  5. Result: “index.php” is appended to the address of the forum if the user is not an admin.
 
I am not able to reproduce that.

I can manually add index.php to the URL when a guest, which remains, but then I can also add 'blah' or 'moo' which also remains, as it is the error page which is being served to non-admins when the board is closed, not a specific page.
 
Are you logged out of the forum? You should be logged out, or be logged in as a non-admin? Did you meet these conditions in your tests?
 
I can reproduce it, basically when the board is not active, going to the website will show the index.php file, but if the board is active, it removes the index.php file
 
That's no bug! The redirect /index.php to / comes from the controller class/method XF\Pub\Controller\Forum::actionList():

PHP:
        $selfRoute = ($this->options()->forumsDefaultPage == 'forums' ? 'forums' : 'forums/list');

        $this->assertCanonicalUrl($this->buildLink($selfRoute));

If the forum is closed and you are not an admin, this code is never executed. The class/method XF\Pub\Controller\AbstractController::assertBoardActive() stops the process before the Forum controller is even loaded:

PHP:
    public function assertBoardActive($action)
    {
        $options = $this->options();
        if (!$options->boardActive && !\XF::visitor()->is_admin)
        {
            $reply = $this->message(new \XF\PreEscaped($options->boardInactiveMessage), $this->app->config('serviceUnavailableCode'));
            $reply->setPageParam('skipSidebarWidgets', true);

            throw $this->exception($reply);
        }
    }

also note: If you change the "Index page route" option in admin cp, then there might be no redirect at all, if you visit /index.php, because $this->assertCanonicalUrl() is not part of all controllers. You can test this with help/ as "Index page route".
 
It certainly is not in line with XenForo’s description of “Use full friendly URLs”:
Read the sentence again: It says "links generated by the system" (this means the frontend in particular) and not "URLs you enter manually or follow during maintenance mode". :rolleyes:
 
Read the sentence again: It says "links generated by the system" (this means the frontend in particular) […]
Exactly, and it's broken:
  1. the link in the upper left corner of the ACP is generated by the system;
  2. the address the link resolves to belongs to the front-end and is unfriendly.
[…] and not "URLs you enter manually or follow during maintenance mode".
Whom are you quoting?
 
the link in the upper left corner of the ACP is generated by the system;
but not the fronend. The admin cp can be called "backend".

btw: you are missing the point of "friendly urls": This means, that the route is not appended to index.php?.

the address the link resolves to belongs to the front-end and is unfriendly.
Visit https://xenforo.com/community/index.php?help/ - there you have an index.php? in the URL as well, because no redirect is implemented in the Help controller. This is also not a bug tough, because this link was not generated by the system.
 
but not the fronend. The admin cp can be called "backend".
Firstly, the back-end does generate a friendly URL under one set of conditions (board is active), and it does not under another set of conditions (board is inactive). So back/front-end distinction does not remove the inconsistency in behavior.

Secondly, the address of the link resolves in the front-end and it is exposed to the users of the front-end. Isn't this—the public appearance of links—the whole point of URL friendliness?

This is also not a bug tough, because this link was not generated by the system.
This thread is about a case that is generated by the system.

It may or may not be intentional. Let the developers have a say.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.12).

Change log:
Dynamically build link to front-end in the control panel
There may be a delay before changes are rolled out to the XenForo Community.
 
I've adjusted the link in the control panel so it is dynamically generated, which should mitigate this, but it is true that URL canonicalization won't happen when the board is not active.
 
Back
Top Bottom