There is a chance this has been answered elsewhere – I have searched as thoroughly as I can here and elsewhere.
I have the following errors on my site, wonkylogic.co, (hosted on LAMP server on Digital Ocean, I followed their tutorials):
- Could not create directory for theme installation. I manually created the directory over ssh to fix this; but may still be relevant to my other errors.
- When updating a page: “Publishing failed. The response is not a valid JSON response.” I’ve found various “solutions” to this: editing .htaccess multiple ways, editing Apache config, editing urls in mysql database. Tried them all and they didn’t fix anything. Change permalinks to plain or /index.php/<post_name>. Changing permalinks works – I can update pages. But obviously this isn’t a real solution because now I have SEO unfriendly urls and all external links to my site are broken.
- Navigation to webpages generates a 404 error. This is fixed by changing the permalinks as in 2. above. Again not an ideal fix.
So the overarching questions are “Why is my site broken this way?” and “How do I fix the root problem?”
Additional context: I migrated my site from shared hosting to Digital Ocean using WP-migrate plugin. It appeared to work for a while, got totally broken after installing SSL with Let’s encrypt. I’ve basically rebuilt the LAMP stack and after much blood sweat and tears got my site vaguely visible as it is now (http only right now – one step at a time).
As an interim measure I will set up some custom redirects to the new urls for external visitors using a plug-in I’ve found.
Update: it seems that my website may not even be accessible, I’m not sure why but I can access it via Safari, but not with Chrome or Firefox.
Seeing what’s in .htaccess was requested.
==================== .htaccess ====================
#Block the include-only files.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
</IfModule>
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPres>
# dynamically generated, and should only be modified via WordPress f>
# Any changes to the directives between these markers will be overwr>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
================== END .htaccess ==================
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I have finally figured out the root cause of why I was getting the invalid JSON response and why permalinks had to be set to include index.php in all urls.
My Apache configuration file was not allowing overrides and I think that means WordPress was unable to alter files in my directory.
The setting for my directory was:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
This was changed to:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Errors no longer plaguing my site. Thank you to everyone who took the time to respond.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0