DigitalOcean WordPress Droplet – .htaccess File

I am again hopping between hosting providers due to lack of SMTP support or simply too expensive. So after a bit of research (about 5mins on Google!) I came across DigitalOcean and their $5 per month instance, so thought I’d give it a go!

I have moved both this WordPress site and one other across using the “All-in-One WP Migration” plugin and was very happy with the DigitalOcean script to create the site and SSL certificate (more on that in another post!) ready to use the migration plugin to import the site – after obviously previously exporting the old site.

Everything was going swimmingly until I came to create a post and got the following rather annoying error:

the response is not a valid JSON response

Off I went to Google again to try and fix the issue and came across a post stating that it could be a an SSL issue. This made a bit of sense as I had obviously changed the SSL certificate so carried on reading. The post stated to install the “Really Simple SSL” plugin and change a couple of settings. I followed along but then got an odd error about .htaccess not being writable. I looked into this and it wasn’t that the www-data user didn’t have access to .htaccess, it was the fact that the file didn’t even exist!

I used PuTTY to connect into the server and navigated to the following location before creating a new .htaccess file:

vim .htaccess

I then copied the following config into the file from the main WordPress site before saving:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Finally, I had to change the permissions on the file via the following:

chown www-data:www-data .htaccess

After I did all of this I was back to being able to upload images and create posts!


Leave a Reply

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