403 redirect override

Created on 28 February 2025, 4 months ago

Problem/Motivation

If I use a custom page redirect, like "/user/login/" for 403, the theme overrides it and still shows the stock 403 page.
Also, the link "go back" does not account for {{ base_url }}.

If you delete/rename the page--403.html.twig file, works as intended.

🐛 Bug report
Status

Active

Version

1.4

Component

Twig

Created by

🇵🇹Portugal Miguel Andrade

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Miguel Andrade
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • First commit to issue fork.
  • Pipeline finished with Success
    3 months ago
    Total: 166s
    #469308
  • Merge request !13Update 2 files → (Open) created by sagartiwari
  • Pipeline finished with Success
    3 months ago
    Total: 164s
    #470339
  • 🇮🇳India sagartiwari

    I've created a merge request to address the issue reported regarding custom page redirects for 403 errors. As noted, when using a custom redirect like /user/login/ for 403 pages, the theme override still displays the default 403 page. Additionally, the "Go back" link does not correctly handle {{ base_url }}.

    I've resolved this by adding the necessary logic in a preprocess function and updating the page--403.html.twig template accordingly. With these changes, the redirect works as expected, and the link respects the correct base URL.

    Please review the MR when you get a chance. Feedback is welcome!

    Thanks!

  • Status changed to Needs work 16 days ago
  • Hello,
    I followed the steps below to review the issue:

    1. Installed the theme version 1.4.3 in Drupal version 10.4.8.
    2. Checked the page /user/1 in anonymous view. Found the 403 default page.
    3. In Basic site settings, I configured the 403 page to redirect to /node. Revisited the page in step 2. Noticed the page is still showing the 403 default page.
    4. Applied MR!13 cleanly.
    5. Repeat step 3; it appears the redirection is corrected, the actual /node page is visible instead of the default 403 page. Checked by adding different redirection paths and also without. All worked correctly.

    After applying the patch, the Back to Home button is redirecting to the same page. I think the Back to Home should redirect to the home ( Default front page ) of the site; redirecting to the same page with the button text "Back to Home" is not logical. IMO, using / instead of {{ base_url }} would be proper.
    Attaching SS for reference. Moving to NW.
    Thanks

Production build 0.71.5 2024