vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   Mini Mods - HTTP Error Response Codes by BOP5 (Soft 404 Solution) (https://vborg.vbsupport.ru/showthread.php?t=309415)

PattiOz 05-07-2014 06:52 AM

Brilliant. Perfect. Works like a charm! My SEO thanks you.

Boothby 05-17-2014 07:21 AM

Hi Joe. Could you add the following codes for search-results?

404 Not Found for no result found

410 Gone for outdated search-ID

When a distinction is not possible then the 410 code should be presented.

Thx

BirdOPrey5 05-17-2014 11:09 AM

Quote:

Originally Posted by Boothby (Post 2498126)
Hi Joe. Could you add the following codes for search-results?

404 Not Found for no result found

410 Gone for outdated search-ID

When a distinction is not possible then the 410 code should be presented.

Thx

Please "Mark as Installed"


Updated to version 1.1
. I wasn't able to determine whether it was no results found or outdated id however, so I added a new setting that will be the response code for any search.php errors. The default response for this is now 410.

I also added code that will prevent the mod from breaking your site if you install it on PHP 5.4+ but later you or your web host downgrade back to PHP 5.3. (Which happened to me.)

This was a minor code change so I believe it worked but I was unable to test it- if someone could test and confirm it works I'd appreciate it.

Boothby 05-17-2014 09:36 PM

Thx Joe. The question came from a member of vb-germany.org who wanted a 404 status code for search. And your mod was the closest. And now it fits perfectly. ;)

BirdOPrey5 05-18-2014 01:38 AM

Thanks. I would like to add however the better way would be for search.php to be off limits via a robots.txt file so Google doesn't try to index search links at all.

This is a generic VB robots.txt file for a forum in the /forums/ directory of a website-

Code:

User-agent: *
Disallow: /forums/admincp/
Disallow: /forums/clientscript/
Disallow: /forums/cpstyles/
Disallow: /forums/customavatars/
Disallow: /forums/customprofilepics/
Disallow: /forums/images/
Disallow: /forums/modcp/
Disallow: /forums/attachment.php
Disallow: /forums/editpost.php
Disallow: /forums/image.php
Disallow: /forums/misc.php
Disallow: /forums/moderator.php
Disallow: /forums/newattachment.php
Disallow: /forums/newreply.php
Disallow: /forums/newthread.php
Disallow: /forums/online.php
Disallow: /forums/poll.php
Disallow: /forums/postings.php
Disallow: /forums/printthread.php
Disallow: /forums/private.php
Disallow: /forums/profile.php
Disallow: /forums/register.php
Disallow: /forums/report.php
Disallow: /forums/reputation.php
Disallow: /forums/search.php
Disallow: /forums/sendmessage.php
Disallow: /forums/subscription.php
Disallow: /forums/threadrate.php
Disallow: /forums/usernote.php


Boothby 05-21-2014 07:04 AM

Those who have < PHP5.4 can add the following at the beginning of the error_generic plug-in and test it. This is a non standardized method, so it may or may not work.

PHP Code:

if (!function_exists('http_response_code'))
{
    function 
http_response_code($newcode NULL)
    {
        static 
$code 200;
        if(
$newcode !== NULL)
        {
            
header('X-PHP-Response-Code: '.$newcodetrue$newcode);
            if(!
headers_sent())
                
$code $newcode;
        }       
        return 
$code;
    }


source: http://www.liketly.com/forum/thread/...response-code/

Thanks to RolandCP for the hint.

DemOnstar 05-21-2014 08:31 AM

1 Attachment(s)
I have 96 warnings from webmaster tools.

https://vborg.vbsupport.ru/attachmen...1&d=1400664625

Not entirely sure how to deal with them and if this is the correct procedure but installed to see what happens.

BirdOPrey5 05-21-2014 10:17 AM

Quote:

Originally Posted by Boothby (Post 2498747)
Those who have < PHP5.4 can add the following at the beginning of the error_generic plug-in and test it. This is a non standardized method, so it may or may not work.

PHP Code:

if (!function_exists('http_response_code'))
{
    function 
http_response_code($newcode NULL)
    {
        static 
$code 200;
        if(
$newcode !== NULL)
        {
            
header('X-PHP-Response-Code: '.$newcodetrue$newcode);
            if(!
headers_sent())
                
$code $newcode;
        }       
        return 
$code;
    }


source: http://www.liketly.com/forum/thread/...response-code/

Thanks to RolandCP for the hint.

Wow- I tested this on 3 forums (1 VB 3.8, 2 VB 4.x) and it worked fine on all 3. :up:

You should copy the code to the top of both plugins however.

Do you mind if I add the code to the plugin?

BirdOPrey5 05-21-2014 10:17 AM

Quote:

Originally Posted by DemOnstar (Post 2498757)
I have 96 warnings from webmaster tools.

https://vborg.vbsupport.ru/attachmen...1&d=1400664625

Not entirely sure how to deal with them and if this is the correct procedure but installed to see what happens.

You should ignore those- the robots.txt is doing what it is supposed to do.

addamroy 05-21-2014 10:28 AM

damn, my host's server (urljet) is using a prior version of php :(

I was all excited to install this lol

DemOnstar 05-21-2014 11:15 AM

I tested the urls using the site that you provided and do still show status 200.

Quote:

Originally Posted by BirdOPrey5 (Post 2498766)
You should ignore those- the robots.txt is doing what it is supposed to do.

Cheers Joe, as you say...

BirdOPrey5 05-21-2014 12:32 PM

Quote:

Originally Posted by addamroy (Post 2498767)
damn, my host's server (urljet) is using a prior version of php :(

I was all excited to install this lol

See post 46 b& 48, I have URLjet and it is working with those changes.

BirdOPrey5 05-21-2014 12:33 PM

Quote:

Originally Posted by DemOnstar (Post 2498773)
I tested the urls using the site that you provided and do still show status 200.

What URL did you test?

CAG CheechDogg 05-21-2014 02:09 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2498765)
Wow- I tested this on 3 forums (1 VB 3.8, 2 VB 4.x) and it worked fine on all 3. :up:

You should copy the code to the top of both plugins however.

Do you mind if I add the code to the plugin?

What does this exactly do BOP5? I installed this on my forums using 5.4 "then" reverted my PHP back to 5.3 since my website not my forums wont work with 5.4 ...I have an old version of Joomla as my CMS which is nicely bridged with my VB forums so using 5.4 is not even an option so I have to stick with 5.3..

Boothby 05-21-2014 02:29 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2498765)
Do you mind if I add the code to the plugin?

Joe, feel free to use this code. I see no problems not to do so. Look at the small source-link. I think this code is too generic so that everyone can use it. :)

BirdOPrey5 05-21-2014 02:46 PM

Quote:

Originally Posted by Boothby (Post 2498793)
Joe, feel free to use this code. I see no problems not to do so. Look at the small source-link. I think this code is too generic so that everyone can use it. :)

Great, thanks! Mod has been updated to version 2.0 to include this code. No longer limited to PHP 5.4.0 or higher.

Quote:

Originally Posted by CAG CheechDogg (Post 2498791)
What does this exactly do BOP5? I installed this on my forums using 5.4 "then" reverted my PHP back to 5.3 since my website not my forums wont work with 5.4 ...I have an old version of Joomla as my CMS which is nicely bridged with my VB forums so using 5.4 is not even an option so I have to stick with 5.3..

Suggest you upgrade to version 2.0. If it can work, it will work. It should not cause any errors on your site even if the code doesn't work for some reason.

The new code attempts to change the response code if it can (which isn't guaranteed on old PHP versions) but it won't bug out if it can't it just won't do anything.

addamroy 05-21-2014 03:16 PM

Saweeet.

Installed.

CAG CheechDogg 05-21-2014 03:37 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2498794)
Great, thanks! Mod has been updated to version 2.0 to include this code. No longer limited to PHP 5.4.0 or higher.

Suggest you upgrade to version 2.0. If it can work, it will work. It should not cause any errors on your site even if the code doesn't work for some reason.

The new code attempts to change the response code if it can (which isn't guaranteed on old PHP versions) but it won't bug out if it can't it just won't do anything.

Good stuff BOP5 and thanks Boothby for the addition !

Boothby 05-21-2014 06:00 PM

I looked in the whole code and I think that this small piece can give false results, when working with the custom pre-5.4 http_response_code() function:

PHP Code:

... http_response_code() != $vbo['bop5he_noperm_err'] ... 

Then I have 2 suggestions:

First I found a way to look for outdated searchids. Second maybe we should send a 503 code for forum closed and server too busy?

PHP Code:

// hook: search_before_process, only for >vB4.0
// outdated searchids
if(is_object($this) AND $this->results === null)
{
    
define('ERR_RESPONSE_CODE'410);


PHP Code:


// ERR_RESPONSE_CODE somewhere defined in the whole wide world?
if(defined('ERR_RESPONSE_CODE'))
{
    
http_response_header(ERR_RESPONSE_CODE);
}
// server to busy
else if($vbulletin->loadcache['loadavg'] > $vbulletin->options['loadlimit'])
{
    
http_response_header(503);
    
header('Retry-After: 60'); // 60 seconds is ok, isn't it?
}
// forum closed
else if(
    !
$vbulletin->options['bbactive']
        AND
    !
in_array(THIS_SCRIPT, array('login''css''mobile'))
)
{
    
http_response_header(503);
    
header('Retry-After: 3600'); // 1 hour, put this in a new option?
}
// and your original code
else if (THIS_SCRIPT == 'search')
{
    
http_response_code($vbo['bop5he_ser_err']);
}
else
{
    
http_response_code($vbo['bop5he_gen_err']);


untested :D

BirdOPrey5 05-21-2014 09:12 PM

Boothby - These are some great ideas- thanks- I will incorporate most, if not all, into the next version. I will list you as a co-author. :)

What is the logic behind this line-
PHP Code:

!in_array(THIS_SCRIPT, array('login''css''mobile' 

Why should we check what script it is on if the board is turned off?

Boothby 05-22-2014 03:54 AM

This is original from vB_Bootstrap::check_state()

Maybe we should use the whole part, esp. the pemission check?

PHP Code:

        // check that board is active - if not admin, then display error
        
if (
            !
defined('BYPASS_FORUM_DISABLED')
                AND
            !
$vbulletin->options['bbactive']
                AND
            !
in_array(THIS_SCRIPT, array('login''css''mobile'))
                AND
            !(
$vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'])
        )
        { 


BirdOPrey5 05-22-2014 09:45 AM

Quote:

Originally Posted by Boothby (Post 2498901)
This is original from vB_Bootstrap::check_state()

Maybe we should use the whole part, esp. the pemission check?

PHP Code:

        // check that board is active - if not admin, then display error
        
if (
            !
defined('BYPASS_FORUM_DISABLED')
                AND
            !
$vbulletin->options['bbactive']
                AND
            !
in_array(THIS_SCRIPT, array('login''css''mobile'))
                AND
            !(
$vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'])
        )
        { 


I see- those exceptions are so a site Administrator can still log in even with the forum off. The purpose of this mod is to return codes so search engines are aware of the status of the page- a search engine would never be browsing the site as an administrator... Also simply changing the response code doesn't prevent the page from loading in a browser- so I am confident we don't need the permission check or the script check.

Going to have an update available later today. :up:

BirdOPrey5 05-23-2014 09:01 AM

Updated to version 2.2. Added options for board closed, and board too busy. Added Boothby as supporter/co-author.

RichieBoy67 05-23-2014 12:54 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2499085)
Updated to version 2.2. Added options for board closed, and board too busy. Added Boothby as supporter/co-author.

Nice work BOP!

Mecho 05-24-2014 09:03 AM

i've got "Possible outages" message from Google :

Quote:

While crawling your site, we have noticed an increase in the number of transient soft 404 errors around 2014-05-08 13:00 UTC (London, Dublin, Edinburgh). Your site may have experienced outages. These issues may have been resolved
the example of links that google sent is alive!! I've sent the exact message to you via pm.

Thanks

BirdOPrey5 05-24-2014 09:29 AM

"transient soft" means that the 404 code was never sent- and as the URLs you sent me were to regular threads and not pages that should usually trigger a vBulletin Error message...

I see they message was dated May 8th - Is it possible your site really had a small outage? I would upgrade to the latest version and monitor to see if you get more issues.

Mecho 05-24-2014 10:22 AM

no outage , and i've updated to the latest version today to see the result.

the thing is that traffic has been dropped in last few weeks. it can be from many different things but in this case i'm afraid that this plugin send the same wrong message for exists threads to search engines and indexed links goes down and traffic either.

that's a guess only. correct me if i'm wrong.

thanks

Boothby 05-24-2014 10:39 AM

Can it be that google can index from public hidden content on your forums?

RichieBoy67 05-24-2014 11:03 AM

I monitor traffic on a daily basis on my sites and clients sites and have this installed on 3 different forums now and I have not noticed any change at all. I am using php4.3 though right now so that could be the reason. It may take time to show any changes in error pages as well.

I plan on upgrading php next week.

Is there any way to test this to see if it works? I have tried but I cannot tell a difference.

CAG CheechDogg 05-24-2014 11:42 AM

Quote:

Originally Posted by RichieBoy67 (Post 2499198)
I monitor traffic on a daily basis on my sites and clients sites and have this installed on 3 different forums now and I have not noticed any change at all. I am using php4.3 though right now so that could be the reason. It may take time to show any changes in error pages as well.

I plan on upgrading php next week.

Is there any way to test this to see if it works? I have tried but I cannot tell a difference.

Use this link, http://httpstatus.io/ ...once you put your link to test, once the test is done hover over the 200 code green box and you should see the response code change ....

If I understand how this works, the test gives you a 200 in the little green box but you see the response code once you hover over it ....hope that helps and hope I am giving you correct information lol ...

RichieBoy67 05-24-2014 11:56 AM

Quote:

Originally Posted by CAG CheechDogg (Post 2499203)
Use this link, http://httpstatus.io/ ...once you put your link to test, once the test is done hover over the 200 code green box and you should see the response code change ....

If I understand how this works, the test gives you a 200 in the little green box but you see the response code once you hover over it ....hope that helps and hope I am giving you correct information lol ...

Thanks bro, awesome!

Just to verify here I am doing this correctly, One test would be to put a non existent path into the form and it should show a 404 error instead of the Vbulletin no permission page?

I think I may be a little confused as to what this does. This does not change error pages but rather response header code so those pages are no longer crawled therefor reducing soft errors and the like?

CAG CheechDogg 05-24-2014 12:14 PM

Quote:

Originally Posted by RichieBoy67 (Post 2499206)
Thanks bro, awesome!

Just to verify here I am doing this correctly, One test would be to put a non existent path into the form and it should show a 404 error instead of the Vbulletin no permission page?

I think I may be a little confused as to what this does. This does not change error pages but rather response header code so those pages are no longer crawled therefor reducing soft errors and the like?

Yes correct, if I understand it correctly that's how its supposed to work ...

BirdOPrey5 05-24-2014 06:05 PM

Quote:

Originally Posted by RichieBoy67 (Post 2499206)
Thanks bro, awesome!

Just to verify here I am doing this correctly, One test would be to put a non existent path into the form and it should show a 404 error instead of the Vbulletin no permission page?

I think I may be a little confused as to what this does. This does not change error pages but rather response header code so those pages are no longer crawled therefor reducing soft errors and the like?

Not exactly...

This mod kicks in when vBulletin shows a vBulletin generated error message.

One way to test it is to test a thread URL such as-

Code:

http://www.qapla.com/mods/showthread.php/1203
(you will see that URL works and response code will be 200)

then change the thread number to something much higher, that you don't have a valid thread for like-

Code:

http://www.qapla.com/mods/showthread.php/999999999999
Now that should return a 404 response code... If this mod wasn't enabled then that URL would return a 200 response code. The 404 proves the mod is working.

Be aware when testing on your own forum the exact URL may be cached by the status checker... so if you test before the mod is installed be sure to use a different URL (even if it is just a little different) when you test again after installing the mod.

If you used a URL that doesn't exist at all like
Code:

http://www.qapla.com/mods/shugugaga
That returns a 404 response because your server is producing a 404 page, vBulletin isn't running at all in this case, it has nothing to do with this mod.

BirdOPrey5 05-24-2014 06:08 PM

Quote:

Originally Posted by Mecho (Post 2499189)
no outage , and i've updated to the latest version today to see the result.

the thing is that traffic has been dropped in last few weeks. it can be from many different things but in this case i'm afraid that this plugin send the same wrong message for exists threads to search engines and indexed links goes down and traffic either.

that's a guess only. correct me if i'm wrong.

thanks

I really don't believe this mod could have caused the Google issues- the hook it runs on simply isn't even executed unless vBulletin is already showing an error message. The error message must be called first, it can't call the error message itself.

puertoblack2003 05-24-2014 09:44 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2499244)
I really don't believe this mod could have caused the Google issues- the hook it runs on simply isn't even executed unless vBulletin is already showing an error message. The error message must be called first, it can't call the error message itself.

This mod has nothing to do with it. I had that issue way before installing this.I had an occasion server hiccup when sometimes it'll go off line for a couple of minutes. i'm guessing during the time google is indexing. If i remember correctly google has a feature when that happens to mark as fix.. can remember though.

tbworld 05-24-2014 09:57 PM

Nice work @BirdoPrey, and thanks @Boothby! :)

AusPhotography 05-25-2014 11:35 AM

Thanks, working perfectly

BirdOPrey5 05-27-2014 02:44 PM

Updated to version 2.1.1. Fixed error on for VB 3.x users on legacy PHP versions (below 5.4.0)

joeychgo 06-04-2014 11:10 AM

Joe, see this thread...

http://www.vbulletin.com/forum/forum...l-css-problems

BirdOPrey5 06-04-2014 11:16 AM

Quote:

Originally Posted by joeychgo (Post 2500642)

What version of PHP is on your server?

What exact version of this plugin was installed?


All times are GMT. The time now is 06:14 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01509 seconds
  • Memory Usage 1,894KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (8)bbcode_php_printable
  • (21)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete