For couple of days I am experiencing issues with modifying some of my posts.
When I try to modify the content of post, I get 404 error, redirecting me that page is not found.

Doing Google research, with all basic tests, clear cache, browser, enable/disable plugins, changing permalinks, etc, I’ve found this on WP forum, saying that Apache’s ModSecurity is causing issues:

https://wordpress.org/support/topic/clicking-the-post-draft-button-sometimes-redirects-a-404-not-found-page/

https://wordpress.org/support/topic/404-page-not-found-when-savingupdating-a-postspage/

However, this doesn’t work for me, because I don’t option in Cpanel to disable ModSecurity – disabled from hosting company.

I’ve got this response from them:

Mod_sec is an important server level security feature. We are not
going to disable mod_sec.

Certain WordPress posts (such as ones that appear to be SQL injection
attacks) may trigger mod_sec, but it certainly is not all WordPress
posts.

Is there any work-around to solve this? I have a SSH access, bit limited, but may helps.

Also, I am not 100% sure about – but I’ve noticed that I can(haven’t test all) update my old posts.

Posts that are ~ 5-6m old are throwing 404 error.
WP version is 4.7.2

EDIT

The only option I have now, is to do a backup of production site, load on my locahost, update posts and push it back to production.

However, this isn’t convenient at all. 🙁
Does anyone have a solution?

Please help!
Thanks!

4 Answers
4

If you have access to remote MySQL, this MIGHT help you. I’ve done this a while ago when i had another issue with my hosting provider.

Take a full backup of your WordPress files, but not your database. Copy them to your localhost. Now, instead of using a local database, in your wp-config.php file, set your database to the remote database of your online website (obviously make a backup first).

define('DB_HOST', 'YOUR REMOTE DATABASE');

Now, force the local installation to use the localhost as Site URL and Site Address, by defining these in wp-config.php :

define('WP_SITEURL', 'http://localhost/');

define( 'WP_HOME', 'http://localhost/' );

Now, you can disable mod_sec on your local Apache web server and update your posts.

PS: I did not try this with mod_sec, and i do not guarantee this to work for you. I don’t even know if this is officially confirmed, but since i did this myself and worked, i considered sharing it with you (since it was too long to post as a comment). I don’t even know if it’s secure or not.

However, be warned about hardcoded URLs and uploads, because these will cause an issue if you are trying to upload files while on localhost. But modifying the content itself, shouldn’t cause a problem.

PS 2 Please be gentle with your downvotes. Although it may look more like a science-fiction project, but it personally worked for me, so i can’t accept people telling me this will never work.

Leave a Reply

Your email address will not be published. Required fields are marked *