How to Solve Error Message .htaccess: Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration in Linux Ubuntu 19.10 Operating System

Posted on

This is an article where the main focus is to handle the error message as in the title. The error mesage is ‘.htaccess: Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration’. It exist as part of the error log of the Apache Webserver. Basically, the error appear in the error log file upon accessing a web-based page. That web-based page has a Yii platform as its framework. Furthermore, there is a ‘.htaccess’ file in the root folder of the web page. The ‘.htaccess’ file actually support  the URL modification of the web page itself. The following is the actual content of the .htaccess file :

RewriteEngine on

# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php

The following is the actual error log file content showing the error message :

[Thu Jan 02 08:30:58.217461 2020] [core:alert] [pid 3886] [client 127.0.0.1:46030] xxxxxxxxxxxxxxxxxxxxxxxxxxx/web/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

Below is an image showing the error on accessing the web-based application via web browser :

How to Solve Error Message .htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration in Linux Ubuntu 19.10 Operating System
How to Solve Error Message .htaccess: Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration in Linux Ubuntu 19.10 Operating System

The solution for the above problem is actually quite simple. Just activate the ‘rewrite’ module for the Apache Webserver. It is in case the execution of the web application is actually using the Apache Webserver. So, in order to activate the ‘rewrite’ module, just execute the following command :

a2enmod rewrite

Don’t forget to restart the Apache Webserver after successfully execute the above command. The above command execution assuming that the environment of the Apache Webserver is in the Linux Ubuntu 19.10.  Generally it is in the Linux Ubuntu distribution type or other type with the same flavor. If it is another type of distribution, it will have a different method or mechanism to activate it. It is also has a different type of method or mechanism if it is a different type of Webserver instead of Apache Webserver. For an example the Nginx Webserver. In order to check for more detail about how to activate the ‘rewrite’ module on Apache Webserver, just visit the following link. It is a link to an article with the title of ‘How to Activate mod_rewrite Apache Webserver Module in Linux Ubuntu 19.10 Operating System’.

Leave a Reply