It should get rid of the “[an error occurred while processing this directive]” error, and will fix many other annoying WordPress issues arising from file permissions.
I recently transferred my WordPress website to a new host.
After I deployed the backup, I got the lovely 500 Internal Server Error message the first time I went the website.
So, I replaced my super-customized .htaccess file with the WordPress default .htaccess file [download here].
That got rid of the 500 error, but then when I refreshed the page, I got…
I poked around with FTP and noticed that the permissions of files and folders on the site had all been set to 666. I deleted all the files and extracted my backup using a different method … same result. “OK,” I thought. “Maybe the backup is bad, but I don’t have another one.”
Using FTP, I had a look through a couple other functional WordPress websites and noticed that:
- all files had their permissions set to 644
- all directories were set with 755 permissions.
I’ve found that incorrect file permissions are usually the reason why a WordPress website doesn’t work after moving it to a different server or host. Honestly, it’s my #1 frustration with WordPress and has, on occasion, ruined entire days for me. Usually, I just use FileZilla to set the permissions — but that can take hours!
So, I decided it was time to create (or find) a PHP script that would recursively go through every single directory on my site and set permissions automatically.
After a bit of Googling and testing, I was able to put a PHP script together which completely fixed the problem.
To fix this annoying issue on your website:
- Download this PHP script which will automatically set permissions of all directories to 755, and all files to 644.
- If you need, you can edit the script to change the permissions to any other value.
- Unzip it and upload the PHP file to the root folder of your website.
- Go to yourdomain.com/php_permissions_755_644.php
- After a moment, a list of files and directories will appear, which means the script has set the permissions successfully.
As always, I recommend deleting the script from your server once you’ve used it – it’s not the kind of thing you want to leave around for a hacker to exploit.
Script borrowed/hacked/modified from this Stack Overflow page.