I was previously running a .htaccess
file on my local development version of my Wordpress site without any issues, but making the equivalent changes to the .htaccess
file on my production site results in the entire site returning Error 500s.
The site is structured on the server like so:
- www.mydomain.com
-- logs
-- public_html
--- (Wordpress root folder)
--- .htaccess
--- index.php
-- webstats
Here is the modified .htaccess
file that I'm trying to get running on the site:
#START WORDPRESS
RewriteEngine On
RewriteBase /public_html/
RewriteRule ^about/?$ /public_html/about/history/ [L,NC,R=301]
RewriteRule ^library/?$ /public_html/the-library/gallery/ [L,NC,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
#END WORDPRESS
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
My understanding of the .htaccess syntax is very lacking, so I can't be sure what I'm getting wrong in the syntax of the file to cause this issue.
Great shout to anubhava on checking the error.log, I did exactly that and found two discrete errors there.
The first one is the one referenced by Andrea:
I managed to solve this by wrapping the
php_value
block with<IfModule mod_php.c>
and</IfModule>
. Note the lack of a version number aftermod_php
- usingmod_php_7
as recommended in many places didn't work for me.The second error was the following:
Because my .htaccess file was located in my document root (which is
public_html
in the case of Siteground hosting), this only needed to be a/
, and this is also all that was needed in the RewriteRules.My finished
.htaccess
, with no errors and all redirects working as they should, now looks like this: