How to enable mod_rewrite for Apache in CentOS
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.
If not enabled, open Apache module configuration file by using following command.
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.