How to enable mod_rewrite for Apache in CentOS

Date: 10-07-2021

CentOS 7 and later versions have mod_rewrite installed and enabled by default. Open terminal and run the below command to check if mod_rewrite is already enabled in your system.
# httpd -M | grep rewrite
If you see the output like below, mod_rewrite is already enabled in your CentOS linux.
rewrite_module (shared)

If not enabled, open Apache module configuration file by using following command.
#vi /etc/httpd/conf.modules.d/00-base.conf
check the below line
#LoadModule rewrite_module modules/mod_rewrite.so
and remove the # sign at its beginning, to enable mod_rewrite.
LoadModule rewrite_module modules/mod_rewrite.so
If you don’t find the above line, just add it to the configuration file and restart the apache service.

Thank you!

Leave a Reply