Saturday, 9 June 2012

wordpress 404 errors with references to the .htaccess file

apache, the web server, allows certain permissions on folders on the server. The config file for apache by default has:
AllowOverride None
which means that the end-user, such as you or I, cannot and may not specify different access permissions in subdirectories/subfolders using the .htaccess file elsewhere.
Now, since editing the permalinks in Wordpress causes it precisely to rewrite the .htaccess file, which is created inside the Wordpress file collection, and since apache is looking for that file, what was happening was apache was seeing that file, and seeing that its permissions contradicted the main apache config file.
So I had to do two things.
1. Change AllowOverride None to AllowOverride All in the apache conf file
2. Add the line Options SymLinksIfOwnerMatch to the end of the htaccess file like so:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~john/sites/gssa/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~john/sites/gssa/index.php [L]
Options SymLinksIfOwnerMatch
# END WordPress
Now, I reverted the permalinks page in Wordpress to the default, away from what it had been set it to.
That caused Wordpress to rewrite .htaccess AGAIN, into a blank file.
I then decided to use the post-name version of permalinks, because that is my preference; it makes sub-urls in the website make more sense.
This problem is symptomatised by the following errors in the apache error_log:
.htaccess: Options not allowed here -- this means fix the AllowOverride thing (1) above

FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: -- this means add "Options SymLinksIfOwnerMatch" to the .htaccess file.

 Note that whenever you adjust the permalinks settings in Wordpress, it changes the contents of the .htaccess file and rewrites it as user apache. It does this EVERY TIME, so maybe try chown the .htaccess file to root:root/755 

php 7 nightmare

OK so Centos 6 insists on installing php 5.3 and even if you download other RPMs and install them, they do not replace the existing 5.3 whic...