Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-7782

Send HTTP 404 if topic, forum or user do not exist

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.x
    • Fix Version/s: 3.0.8-RC1
    • Component/s: Viewing posts
    • Labels:
      None
    • Environment:
      PHP Environment:
      Database:

      Description

      Currently phpBB shows a "Topic doesn't exist" message when the user tries to open an invalid URL, the URL of a deleted topic or the URL of a topic that's inaccessible to this user. The same goes for forums.

      For bots it would be good if a 404 is returned in these cases because:

      • This makes it easier to erase unwanted information from search engine caches/indices
      • Some bots don't like the fact that random URLs return a 200 statuscode
      • The bot won't need to update the URL (as often) as it would when a 200 is returned
      • It's not very useful to index a "Topic doesn't exist" page

      I've fixed this by adding this around the topic of msg_handler():

              if ($msg_text == 'NO_TOPIC' || $msg_text == 'NO_FORUM')
              {
                      header("HTTP/1.0 404 Not Found");
              }
      

      IMO this is not the cleanest way to fixed this but this saved me quite a bit of work Those two messages are returned in quite a few places...

        Issue Links

          Activity

          Hide
          ToonArmy Chris Smith added a comment -

          Unsuitable fix, it won't reliably work with CGI and the HTTP/1.x isn't correct. We should probably make a reusable function to set the HTTP response code properly. Take a look at set_modified_headers() in download/file.php for an existing example.

          Show
          ToonArmy Chris Smith added a comment - Unsuitable fix, it won't reliably work with CGI and the HTTP/1. x isn't correct. We should probably make a reusable function to set the HTTP response code properly. Take a look at set_modified_headers() in download/file.php for an existing example.
          Hide
          naderman Nils Adermann added a comment -

          Patch looks good to me now. Chris?

          Wouldn't mind a phpdoc comment on the new function though

          Show
          naderman Nils Adermann added a comment - Patch looks good to me now. Chris? Wouldn't mind a phpdoc comment on the new function though
          Show
          Oleg Oleg [X] (Inactive) added a comment - http://github.com/p/phpbb3/commit/691f682fc2a69fed28bdca76f714d20be9277af6
          Hide
          bantu Andreas Fischer added a comment -

          substr(strtolower(@php_sapi_name()),0,3) should have spaces between arguments.

          Show
          bantu Andreas Fischer added a comment - substr(strtolower(@php_sapi_name()),0,3) should have spaces between arguments.
          Show
          Oleg Oleg [X] (Inactive) added a comment - http://github.com/p/phpbb3/commit/d721e94b888b657c8e36729db2c455812308cdc3

            People

            • Assignee:
              naderman Nils Adermann
              Reporter:
              BartVB BartVB [X] (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development