Giter Club home page Giter Club logo

Comments (6)

khalwat avatar khalwat commented on August 24, 2024

You might be able to do this if you set up your webserver to redirect 410 status codes to Craft (the way you have it set up to do that for 404 status codes) and you set up the appropriate Twig template for that status code (again, like you did for 404)

More here: https://nystudio107.com/blog/handling-errors-gracefully-in-craft-cms#handling-exceptions-on-the-frontend

from craft-retour.

gmonseur avatar gmonseur commented on August 24, 2024

Hi @khalwat

Thanks for your help.

In the documentation, it is indicated to create a template with the status code. I've created these:

  • 410.twig
  • error.twig
  • (gone.twig)

But I still get the same blank page
The 404.twig works correctly...
The server seems to be well configured:

HTTP/1.1 410 Gone
Date: Mon, 11 Mar 2024 08:49:26 GMT
Server: Apache/2.4.52 (Ubuntu)
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate
X-Robots-Tag: none
X-Powered-By: Craft CMS
X-Debug-Tag: 65eec596750af
X-Debug-Duration: 97
X-Debug-Link: http://***.local/actions/debug/default/view?tag=65eec596750af
Set-Cookie: 0f76a97cf0214b90e8cddfdfd24c9509_identity=6a84e2d681f2e8519080cf7f534c5adb97072562b53036651841fcaf2e9e61a3a%3A2%3A%7Bi%3A0%3Bs%3A41%3A%220f76a97cf0214b90e8cddfdfd24c9509_identity%22%3Bi%3A1%3Bs%3A159%3A%22%5B1%2C%22%5B%5C%22F216pVZwW2YaaMu28Rd2dAIwAUsgEozA_4lKDybDxKtoGskn2ekItCq6xLzX_srzamVIM14m19Y2cGcUAv6jgii4sSBVQKEa5UgI%5C%22%2Cnull%2C%5C%22f7ec762ae3fce466b0ef48556c80eefd%5C%22%5D%22%2C3600%5D%22%3B%7D; expires=Mon, 11 Mar 2024 09:49:26 GMT; Max-Age=3600; path=/; HttpOnly
X-Content-Type-Options: nosniff
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Authorization
Access-Control-Allow-Methods: GET
Access-Control-Expose-Headers: Content-Security-Policy, Location
Access-Control-Max-Age: 600
Location: http://***.local/410
X-Frame-Options: SAMEORIGIN
Content-Length: 0
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

I don't know.

from craft-retour.

gmonseur avatar gmonseur commented on August 24, 2024

Further information

In vendor/craftcms/cms/src/controllers/TemplatesController.php in actionRenderError fct in line 240

dump($template);
dump($variables);
dump($this->renderTemplate($template, $variables));
exit();

And results

"_errors/410"

array:5 [▼
  "message" => "Page non trouvée."
  "code" => 0
  "file" => "/media/DATA/www/***/vendor/craftcms/cms/src/web/Request.php"
  "line" => 1350
  "statusCode" => 410
]

craft\web\Response {[#442 ▼](http://www.***.local/accessoire/agrafe-a-piquer-#sf-dump-1909957779-ref2442)
  -_events: array:1 [▶]
  -_eventWildcards: []
  -_behaviors: array:1 [▼
    "template" => craft\web\TemplateResponseBehavior {#999 ▼
      +owner: craft\web\Response {[#442](http://www.***.local/accessoire/agrafe-a-piquer-#sf-dump-1909957779-ref2442)}
      -_attachedEvents: []
      +template: "_errors/410"
      +variables: array:5 [▼
        "message" => "Page non trouvée."
        "code" => 0
        "file" => "/media/DATA/www/***/vendor/craftcms/cms/src/web/Request.php"
        "line" => 1350
        "statusCode" => 410
      ]
      +templateMode: null
    }
  ]
  +exitStatus: 0
  +format: "template"
  +acceptMimeType: null
  +acceptParams: []
  +formatters: array:6 [▶]
  +data: null
  +content: null
  +stream: null
  +charset: "UTF-8"
  +statusText: "OK"
  +version: "1.1"
  +isSent: false
  -_statusCode: 200
  -_headers: yii\web\HeaderCollection {#441 ▶}
  -_cookies: yii\web\CookieCollection {#850 ▶}
  +defaultFormatters: []
  -_isPrepared: false
}

from craft-retour.

khalwat avatar khalwat commented on August 24, 2024

Did you set up your webserver to route 410 errors through Craft?

from craft-retour.

gmonseur avatar gmonseur commented on August 24, 2024

It's an Apache server. What do I need to configure?

Server: Apache/2.4.52 (Ubuntu)

from craft-retour.

khalwat avatar khalwat commented on August 24, 2024

I haven't used Apache in a long time, so I don't know off of the top of my head... but you'd want something in your .htaccess to ensure that the webserver itself doesn't handle the 410 error, but rather it should be passed along to Craft so that it can then route it to the correct template.

Maybe this helps: https://stackoverflow.com/questions/65388979/properly-set-redirect-410-gone

from craft-retour.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.