During this weekend on my path to create one website I ran into an issue that took me a while to understand and solve. I am far of being an expert in WordPress and I’m starting learning how it works and how to set it up.
At the beginning, I already had some setup in order to redirect any request to to the https version of the site but I haven’t notice this behavior because I was only working on my laptop and when I just typed “frames and walls”, it already have a direct link to http://framesandwalls.com.
Some initial conditions are met in order to reproduce this error:
- My WordPress installation is in a subfolder.
- I had some code in my .htaccess to redirect all http requests to https.
- If you request any https address, it works as expected.
- If you request any http address, it redirects to the https address adding the subfolder to the URL, this ends up in a 404 page not found.
After that I decided to update the WordPress Address URL so that it points to the subdirectory path, and as soon as I did that, I received an Internal Server Error.
Then I thought that maybe if I rolled back this change it may work again, so I looked into the database and my surprise was that the URL was as the were originally before doing this change.
After this point, any time I tried to direct to my site using any address I received the Internal Server Error. At this point I was thinking on restoring from a previous backup I did before starting these changes, however, I have some locations of my site under version control so that I decided instead to compare what files changed from the last version in the server against my workspace and I noticed the .htaccess at public_html was one of them.
So, I just removed the changes from the .htaccess, uploaded it again through ftp and my Internal Server Error was solved, I was able to access my full website again.
From this I learned a couple of things:
- Version control saved my life this time, so its important to keep it up to date in order to track changes.
- Having backups as well is a good practice, worst case scenario, you can restore from a very recent backup.
- Do a backup before doing any crazy change.
- Having a testing environment will take away a lot of worries.
- Read before doing changes that your gut tells you might break something.
Finally, to solve my original issue, I received some assistance and recommended me to install some plugin to enforce SSL, so I did it and when comparing against version control, I noticed that some php files had hardcoded the URL with the the subfolder.