This problem is caused when apache's mod_version
module is not enabled. Unfortunately, my host does not allow me to enable this module and so I have devised the following workaround:
Step 1
Open [magento_root]/.htaccess
with your favourite text editor.
You will notice, towards the end of the file, there are numerous entries following this format:
<Files composer.json>
<IfVersion < 2.4>
order allow,deny
deny from all
</IfVersion>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
</Files>
<Files composer.lock>
<IfVersion < 2.4>
order allow,deny
deny from all
</IfVersion>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
</Files>
...
Step 2
The exact procedure here is dependent on the version of apache that your server is running. Mine runs 2.4, so I have removed all <IfVersion />
statements and replaced them with the content of their relevant clause, like so:
<Files composer.json>
Require all denied
</Files>
<Files composer.lock>
Require all denied
</Files>
...
This process must be repeated until there are no instances of <IfVersion />
remaining in the document.
Step 3
Open [magento_root]/pub/.htaccess
with your favourite text editor and repeat the process laid out in step 2.
Note: In the event that this process has been carried out and then the apache version is changed (i.e. the server was running apache 2.2 and upgraded to 2.4), then files must be restored by replacing both edited files with the relevant .htaccess.sample
, and following the above process from the beginning.
As mentioned in Erica Southworth's answer, the list I provide is not exhaustive, but it is all that is needed in order to recover basic functionality. Here is the list of all files containing IfVersion
queries, for continuity:
app/.htaccess
bin/.htaccess
generated/.htaccess
lib/.htaccess
phpserver/.htaccess
pub/.htaccess
var/.htaccess
vendor/.htaccess
setup/config/.htaccess
setup/performance-toolkit/.htaccess
setup/src/.htaccess
setup/view/.htaccess
vendor/magento/magento2-base/.htaccess
pub/media/customer/.htaccess
pub/media/downloadable/.htaccess
pub/media/import/.htaccess
pub/media/theme_customization/.htaccess
vendor/magento/magento2-base/vendor/.htaccess
vendor/magento/magento2-base/var/.htaccess
vendor/magento/magento2-base/pub/.htaccess
vendor/magento/magento2-base/phpserver/.htaccess
vendor/magento/magento2-base/lib/.htaccess
vendor/magento/magento2-base/generated/.htaccess
vendor/magento/magento2-base/dev/.htaccess
vendor/magento/magento2-base/bin/.htaccess
vendor/magento/magento2-base/app/.htaccess
vendor/magento/magento2-base/setup/config/.htaccess
vendor/magento/magento2-base/setup/performance-toolkit/.htaccess
vendor/magento/magento2-base/setup/src/.htaccess
vendor/magento/magento2-base/setup/view/.htaccess
vendor/magento/magento2-base/pub/media/customer/.htaccess
vendor/magento/magento2-base/pub/media/downloadable/.htaccess
vendor/magento/magento2-base/pub/media/import/.htaccess
vendor/magento/magento2-base/pub/media/theme_customization/.htaccess
mod_version
is not enabled. If you are having issues withmod_version
then please undo all the changes you made based on this question and follow the instructions in my answer.