This may be impossible, but I am wondering if anyone knows if there is a way to try loading an .htaccess file, and if it causes issues on the site then revert to a backup .htaccess file? Same goes for the wp-config.php file.

EDIT: I have a custom plugin that adds snippets to my .htaccess and wp-config.php. My wish is to try the update, and if it fails, then revert back to the original. I am aware that I can manually revert via FTP, etc. I am looking for a possible solution to do this with a try catch or something. Maybe try catch the function that loads these files? If one exists?

  • Sure, just save backups of the files and update them with SSH, SFTP, or your host's file manager. You may then need to flush whatever levels of caching you have on the site and dump your browser cache to verify everything is working as expected.
    – WebElaine
    Aug 22, 2022 at 13:23
  • @WebElaine, thank you, but I think you misunderstood my question. I have edited it to clarify what I'm trying to achieve.
    – Aristocles
    Aug 22, 2022 at 13:29
  • .htaccess is used outside of WordPress even loads. If it fails then depending on how it fails WordPress is not going to load at all, so your plugin isn’t going to be able to do anything in response. Aug 22, 2022 at 13:39
  • 2
    one of the biggest challenges of this will be how do you test that there are issues with the site so that you know you need to revert?
    – Tom J Nowell
    Aug 22, 2022 at 13:51
  • That was my thought, but I figured I would see if there was an option I'm not aware of. Thanks.
    – Aristocles
    Aug 22, 2022 at 14:38


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.