I’m struggling with this problem since a couple of days, I tried everything I found around but nothing seems to fix the problem.
So, I created this wordpress website on my local machine and deployed it on a test server, untill there no problem, everything works as expected. Then I deployed the website to the prod server and everything works fine except that when I try to add an image to an article, the image isn’t displayed and I get a 404 error on /wp-admin/admin-ajax.php.
Unfortunately, the prod server is one of those crappy web hosting with cpanel that doesn’t give you access to php error logs.
Does someone know how to fix this problem?
Thank you in advance.
4
Answers
I finally found the problem! Apparently, the mod_security module of apache was blocking the page. I disabled it and everything works correctly now.
Delete .htaccess
Login to your admin panel. Go to:
Dashboard -> Settings -> Permalinks -> Save. (just automatically recreates your .htaccess again). That should do the trick.
If the problem persists. Try disabling plugins. Enable plugins 1 by 1 until the problem occurs again. That will narrow down the faulty plugin.
I was getting the admin-ajax 404 due to the ModSecurity.
Try to disable the mod security: Cpanel > Security > ModSecurity.
It was ModSecurity for me as well
If you don’t want to disable the ModSec module entirely, you can whitelist rules for certain pages/actions using the ConfigServer ModSec Control module.
In this case I have added a New DirectoryMatch rule for
/wp-admin/admin-ajax.php
The rules I have whitelisted are
941160
949110
980130
You can tell what rules you need to whitelist by using ModSecurity Tools and looking at recent hits and the corresponding Rule ID