Announcement

Collapse
No announcement yet.

exec_header_redirect response code changed 302 -> 301 in 3.6.8

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • exec_header_redirect response code changed 302 -> 301 in 3.6.8

    In version 3.6.8 the response code for redirects issued by the `exec_header_redirect` function is 302 (temporary) rather than 301 (permanent). This is causing undesirable behavior. Here is the diff between 3.6.7-pl1 and 3.6.8 for that section of code:

    Code:
    Index: vendor/vBulletin/current/upload/includes/functions.php
    ===================================================================
    --- vendor/vBulletin/current/upload/includes/functions.php (revision 4305)
    +++ vendor/vBulletin/current/upload/includes/functions.php (revision 4380)
    @@ -2775,21 +2791,21 @@
     		($hook = vBulletinHook::fetch_hook('header_redirect')) ? eval($hook) : false;
     	}
     
     	$url = str_replace('&', '&', $url); // prevent possible oddity
     
     	if (strpos($url, "\r\n") !== false)
     	{
     		trigger_error("Header may not contain more than a single header, new line detected.", E_USER_ERROR);
     	}
     
    -	header("Location: $url", 0, 301);
    +	header("Location: $url", 0, 302);
     
     	define('NOPMPOPUP', 1);
     	if (defined('NOSHUTDOWNFUNC'))
     	{
     		exec_shut_down();
     	}
     	exit;
     }
    I was unable to find any mention of this in the bug tracker, so I am unsure why this was changed in this version.
    http://www.statgfx.com

  • #2
    What undes. behavior is it causing? And not every code change is listed in details - the bug report could have been internal.

    Comment


    • #3
      It would affect any plugin that uses that function.

      For example, I am using vRewrite which uses that function to redirect from the regular "showthread.php" URL's to alternative URL's. The HTTP response expected is 301 because the redirect should be permanent.

      Another question would be, in what circumstance(s) is 302 preferable in vB that would have led to this change?

      It's not a big deal, since I was able to easily revert this bit of code, but I am curious especially if it will adversely affect something else. From my searches, it appears that there might have at one time been a parameter that could be specified to indicate whether the redirect should be 301 or 302. If 302 needs to be the default for whatever reason then it would be nice to have the option of specifying the redirect response. It seems to me though that in most cases 301 should be the default response.
      http://www.statgfx.com

      Comment


      • #4
        Originally posted by dotcomguy01 View Post
        In version 3.6.8 the response code for redirects issued by the `exec_header_redirect` function is 302 (temporary) rather than 301 (permanent). This is causing undesirable behavior.
        Thank you very much, dotcomguy01, for pointing out the change.

        Originally posted by Floris View Post
        What undes. behavior is it causing? And not every code change is listed in details - the bug report could have been internal.
        Hi Floris, it has caused problems with the SEO for my forum - duplicate content etc.
        Be considerate to your users. Open links in the same window.

        Comment

        Related Topics

        Collapse

        Working...
        X