#367 - Send proper HTTP code for 404 pages
Type Enhancement
Status Completed
Milestone 3.2.2
Version 3.2.1
Component Core
Priority Normal
Severity Normal
Owner Erwin
Assigned to Jack
Reported 11 years ago
Updated 10 years ago
Votes 0
Related tickets
Proposed time
Worked time

Hello,

I have noticed that, if I get a "not found page" (the "He's dead, Jim!" one), Traq doesn't change the HTTP code and so returns a 200 OK. That's not a really important thing, but I think it would be cleaner if Traq could send the proper HTTP status code in such a case.

As far as I understand, I think it could be done in vendor/avalon/core/controller.php, by adding a new key to the $_render array (let's say "http_status" for example) defaulted to null, then adding this line in the show_404 method:

$this->_render['http_status'] = '404';

And in the __shutdown method:

    // Check if we have to send a specific HTTP code
if (!is_null($this->_render['http_status'])) {
        if ($this->_render['http_status'] === '404') {
            header("HTTP/1.0 404 Not Found");
    }
    }    

The same could be done for the no_permission page as well with a 403 Forbidden code.

Ticket History

11 years and 4 months ago by Jack

  • Component Core
  • Closed ticket as Completed
  • Assigned to Jack

Could also just call the header function in the action_404 and show_no_permission methods instead of having a bunch of lines of extra code in the __shutdown method.

11 years and 4 months ago by Erwin

Ok, thank you :) And sorry for the text formatting, it broke for some reason. I suspect a Firefox extension to break editors since I had some issues elsewhere as well, I have yet to find the guilty...