404 detection with 404 template
-
Hi dear,
I’ve set a 404 template (custom 404 page) for my 404 errors and unfortunately AIOS plugin can’t detect and log activities related to 404 pages. How can this problem be fixed?
Previously i got help with Rankmath plugin in this topic: https://support.rankmath.com/ticket/empty-404-monitor-with-404-template/
-
Hi!
Unfortunately, the free plugin does not offer 404 detection.
The Smart 404 detection and logging is a feature that comes with the premium version of the plugin.
If you already have the premium plugin installed, please drop a support request via our premium support channel. We’ll be happy to provide you with further support there.Thanks.
Setting in: brute force > Enable 404 IP detection is a free feature that does not work.
Plugin needs to be adjusted to detect 404 templates.
I mean this setting:
/admin.php?page=aiowpsec_brute_force&tab=404-detection
Hi @e12ror,
I will create an internal ticket to checkin more details
we check
is_404
to detect 404 and record event for it.add_action('wp_head', array($this, 'check_404_event'));
If that page do not return is_404 true then it might be issue.
Regards
@hjogiupdraftplus Thank you.
I’m looking forward to hearing from you soon.
Hi @e12ror
If we cross check for a custom theme which used the WP backery page builder, where it is possible to set the custom 404 page. It do not have the issue and 404 events are logged.
https://snipboard.io/SGZbsk.jpg
https://snipboard.io/jvp8Dh.jpg
Can you please let me know which theme being used there ?
Regards
@hjogiupdraftplus Thanks for double checking the problem.
We’re using woodmart theme, with elementor and elementor pro page builder (all in latest version): https://snipboard.io/qGnNcU.jpg
Rankmath SEO PRO 404 Detection: https://snipboard.io/P5ZaqE.jpg
As I mentioned before, either Rankmath didn’t recognized the 404 pages before this fix: https://support.rankmath.com/ticket/empty-404-monitor-with-404-template/
AIOS 404 detection: https://snipboard.io/aN2uLx.jpg
Hooks check with query monitor plugin:
Rankmath: https://snipboard.io/YsDRE9.jpg
AIOS: https://snipboard.io/vAknQd.jpg
-
This reply was modified 2 months, 2 weeks ago by
moghaddamhreza.
Hi @e12ror,
We use
wp_head
hook for to check the 404 event. incheck_404_event
theis_404
should be found true to log 404 event.Generally for 404 page,
set_404
should be called before thewp_head
https://developer.www.ads-software.com/reference/classes/wp/handle_404/
add_action('wp_head', array($this, 'check_404_event'));
can you please cross check in
check_404_event
using error_log is_404 is set or not.error_log("is 404 set ? ".is_404());
If not check the theme
404.php
template is being called it does havewp_head()
called.I still need to understand how you created the 404 page and why
template_redirect
hook which solved issue for rank math.you can use instead
wp_head
thetemplate_redirect
by changing in code file./wp-content/plugins/all-in-one-wp-security-and-firewall/classes/wp-security-general-init-tasks.php line 310 approx and check if it solves the issue and let me know.
Regards
Yes! after changing wp_head to template_redirect this module works fine.
AIOS 404: https://snipboard.io/2joGgS.jpg
Rankmath 404: https://snipboard.io/9cdYBe.jpg
Hi @e12ror,
Thanks for confirming that changing?wp_head?to?template_redirect works,
We will try check in more details if using template_redirect do not makes any other issue.
There is no answer from your side regarding the theme do have 404.php and is it being executed can you please cross check.
Regards
I’m newbie to developing WP and unfortunately don’t know what “error_log is_404” is and how to call it.
But this informations can be extracted from Query Monitor Template: https://snipboard.io/KLxu5i.jpg
Query Monitor Template Hooks and 404.php file (woodmart theme): https://file.io/sd312gWJEV1y
And yes, the woormart theme have a 404.php file and is included in the file above.
-
This reply was modified 2 months, 1 week ago by
moghaddamhreza.
I checked with AIOS Pro plugin that IP Blocking works or not, but unfortunately it’s not.
Setting: https://snipboard.io/prH95w.jpg , https://snipboard.io/C8dmYz.jpg , https://snipboard.io/txA5In.jpg , https://snipboard.io/n4aNqK.jpg
Results: https://snipboard.io/7AFGxn.jpg with no IP Blocked.
I tested and refreshed a 404 url for 20 times and another test with twenty different 404 pages and nothing happened (with VPN and incognito). I think it should redirected me to 127.0.0.1 at the 10th try with the above settings.
-
This reply was modified 2 months, 1 week ago by
moghaddamhreza.
-
This reply was modified 2 months, 1 week ago by
Steven Stern (sterndata).
Hi @e12ror ,
Its ok if you are newbie and do not check in more details from your side. As this type of issue raised first time. I can assure it is not the general issue that with theme 404 events are not logged.
Thanks for providing info for 404.php template etc
https://snipboard.io/bK2AV9.jpg
I will come up with a code which works in your theme functions.php file and with template_redirect hook it can call AIOS for your website
check_404_event
Unfortunately, www.ads-software.com rules do not allow their forums to be used by us for paid software. for more details regarding that issue you can raise a support ticket at aios website.
But here main issue is of the AIOS Free 404 events are not logged for your theme using
wp_head
and works for thetemplate_redirect
so have to check if it can be applied for all themes.Regards
@hjogiupdraftplus I appreciate your supports provided on this issue
Hi @e12ror,
Can you please add the code below to your theme functions.php file?
It should log the 404 events using template_redirect hook
function template_redirect_aios_404_check() {
global $aio_wp_security;
if (!empty($aio_wp_security) && $aio_wp_security->configs->get_value('aiowps_enable_404_logging') == '1') {
if (is_404()) {
//This means a 404 event has occurred - let's log it!
AIOWPSecurity_Utility::event_logger('404');
}
}
}
add_action( 'template_redirect', 'template_redirect_aios_404_check' );Regards
@hjogiupdraftplus YEAP! This function worked and AIOS now can detect 404 events.
But IP Block function still does not work.
In this case, Should AIOS plugin block IP’s that had 404 events for more than 10 times automatically or not? with this settings: https://snipboard.io/aN2uLx.jpg
-
This reply was modified 2 months, 2 weeks ago by
- The topic ‘404 detection with 404 template’ is closed to new replies.