Enable and Configure mod_rewrite for Apache on CentOS 7

/ By Arjun / Published on September 21, 2017

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.

Add or uncomment the following line:

Save and close the file, then restart the httpd service:

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.

You can do this by editing httpd.conf file:

Find the section and change AllowOverride None to AllowOverride All.

Save and exit.

Now restart Apache to put the change into effect:

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 votes
Article Rating
Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
Helwie Ahmad
Helwie Ahmad
3 years ago

thanks for the great tutorial. you save me. i spen 3d for fix my error server 😀

Would love your thoughts, please comment.x