Yesterday when I was trying to publish a post it was redirecting me to 404 error page. The problem was with only one particular page and it was some way related to the post content. I was able to save the post when I removed some part of the post. I tried a lot of things like
- Disabling plugins
- Activating the default theme
- Updating and reinstalling WordPress
- Rewriting htaccess and updating permalinks
Nothing helped, some of the threads on this problem referred to mod_security rules. The problem was due to the mod security rules. As my post had some strings that directly relate to security issues. These obviously triggered some mod_security rules I had to disable mod_security rules temporarily to publish the post.
This is what I added to /usr/local/apache/conf/modsec2/whitelist.conf, (location may be different in your case)
If don’t have the permissions to edit mod_security rules, ask your hosting support team to update them for you. You may want to show this post as reference to them.