01-Sep-2020 : I killed my Web site!

  • by

Well done, me – I totally killed my own Web site yesterday. I feel stupid but I’m documenting the fix because it might save someone else an hour entering all the wrong search terms into Google and worrying they’ll never sort out the problem.

So, what did I do wrong?  Well, there’s an option in the WordPress Dashboard where you set up your Web site’s URL, and if you get it wrong, WordPress will not be able to find any of your site’s pages.  None of them.  You won’t be able to log back in, reset your password, get back into your Dashboard, or go anywhere else.  Plus some or all of your site might become inaccessible to visitors.

Here’s where I went wrong:-

The image above shows the correct values.  So what was the fix?  You have to access the back end of your Web site using cPanel (or whatever other facility your Web host has provided), then find your home directory.  This will normally be the top level directory visible to you.  Navigate down through public_html and inside that directory look for your site’s WordPress directory, typically called wp, but possibly called something else if your home directory holds multiple WordPress installations.  (Mine also holds a test installation.)  Inside this folder you’ll find a file called wp-config.php:-

Make a backup of wp-config.php, either by downloading it on to your local machine or by copying it to another directory on the host server.  (You may have to create a backup directory for this purpose.)  Don’t skip this step because if you totally screw up the file, you’re going to struggle to replace it.  Now the bit where you have to be very careful.  Open wp-config.php in edit mode and identify where the SQL definitions begin (line 17 or thereabouts), and place your cursor on the blank line immediately above.  Paste the following definitions in at that point, then amend the URLs to point to your own WordPress and Site addresses.  It should end up looking something like this:-

Finally hit Save.  Now you can try to reload your Web site’s home page and check that you can log in and access your Dashboard.  If it still doesn’t work, check that you’ve entered the extra lines in a sensible place, e.g. not inside the comments block, and that you’ve used the correct URL.  (You may be able to verify the correct URL by looking at your Web browser history.)  Whatever you do in cPanel should not stop you accessing cPanel, so if these changes do not fix your problem, restore the wp-config.php file to its original contents and contact your Web host for support. 

Note: if you change your WordPress and Site addresses via the wp-config.php file instead of in the WordPress Dashboard, the WordPress Address (URL) and Site Address (URL) settings in the Dashboard will be greyed out and you will no longer be able to change them in the Dashboard.  I don’t think this is a problem…

Acknowledgements and thanks to HostPapa where I (eventually!) found the solution to my problem in their knowledge base: https://hostpapasupport.com/change-wordpress-home-site-url-settings/.