The mod_rewrite module is enabled by default on CentOS 7. If you find it is not enabled on your server, you can enable it by editing 00-base.conf file located in /etc/httpd/conf.modules.d/ directory.
sudo nano /etc/httpd/conf.modules.d/00-base.conf
Add or uncomment the following line:
LoadModule rewrite_module modules/mod_rewrite.so
Save and close the file, then restart the httpd service:
sudo systemctl restart httpd
Enable .htaccess File
Once the mod_rewrite module has been activated, you can set up your URL rewrites by creating an .htaccess file in your default document root directory. A .htaccess file allows us to modify our rewrite rules without accessing server configuration files. For this reason, .htaccess is critical to your web server. Before we begin, we need to allow Apache to read .htaccess files located under the /var/www/html directory. Continue reading “Enable mod_rewrite for Apache on CentOS 7” »